Class: Iso8601DateValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- Iso8601DateValidator
- Defined in:
- app/validators/iso8601_date_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
4 5 6 7 8 |
# File 'app/validators/iso8601_date_validator.rb', line 4 def validate_each(record, attribute, value) Date.iso8601(record.read_attribute_before_type_cast(attribute).to_s) rescue ArgumentError, TypeError record.errors.add(attribute, _('must be in ISO 8601 format')) end |