-
-
Save paulsonkoly/8a1509775fb93b95381a1d84f5bc2e8b to your computer and use it in GitHub Desktop.
validators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'active_support' | |
| require 'active_model' | |
| class X | |
| include ActiveModel::Validations | |
| include ActiveModel::Attributes | |
| attribute :blah | |
| validates :blah, numericality: { greater_than_or_equal_to: 0 } | |
| validates :blah, numericality: { greater_than_or_equal_to: 3 } | |
| end | |
| x = X.new | |
| x.blah = -1 | |
| x.valid? # => false | |
| x.errors.full_messages # => ["Blah must be greater than or equal to 0", "Blah must be greater than or equal to 3"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment