I want to validate a number :value
to be within 1 or 2
validates :value, :format => { :with => /1|2/, :message => "Select number.." }
However, the above code is failing the validation when value == 1
Please ensure that your solution allows me to add a message for the validation.
validates :value, :inclusion => {:in => [1,2]}
See http://apidock.com/rails/ActiveModel/Validations/HelperMethods/validates_inclusion_of
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With