Class: DatetimeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- DatetimeValidator
- Defined in:
- app/validators/datetime_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 |
# File 'app/validators/datetime_validator.rb', line 2 def validate_each(record, attribute, value) date = DateTime.parse(value.to_s) rescue ArgumentError record.errors.add(attribute, I18n.t(:invalid_date_time, :scope => [:activerecord, :errors, :messages])) if date == ArgumentError end |