Class: Rubykitchen::ValidatesAge::Validator::AgeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Rubykitchen::ValidatesAge::Validator::AgeValidator
- Defined in:
- lib/validates_age.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/validates_age.rb', line 7 def validate_each(record, attribute, value) if value > Date.today record.errors[attribute] << "As per the DOB you are Not yet Born" elsif ((Date.today - value) < 13) record.errors[attribute] << "Your age is less than 13" elsif ((Date.today - value) > 120) record.errors[attribute] << "Your age is older than the oldrst Human Being" end end |