Class: VanillaValidator::Rules::Date
- Defined in:
- lib/vanilla_validator/rules/date.rb
Instance Attribute Summary
Attributes inherited from BaseRule
#attribute, #parameters, #value
Instance Method Summary collapse
Methods inherited from BaseRule
Constructor Details
This class inherits a constructor from VanillaValidator::Rules::BaseRule
Instance Method Details
#failure_message ⇒ Object
14 15 16 |
# File 'lib/vanilla_validator/rules/date.rb', line 14 def I18n.t('date', attribute: attribute) end |
#valid? ⇒ Boolean
4 5 6 7 8 9 10 11 12 |
# File 'lib/vanilla_validator/rules/date.rb', line 4 def valid? begin ::Date.strptime(value, '%Y-%m-%d') true rescue # ArgumentError, TypeError false end end |