Class: MetadataPresenter::DateValidator
- Inherits:
-
BaseValidator
- Object
- BaseValidator
- MetadataPresenter::DateValidator
- Defined in:
- app/validators/metadata_presenter/date_validator.rb
Direct Known Subclasses
Constant Summary collapse
- DATE_STRING_VALIDATIONS =
%w[date_after date_before].freeze
Instance Attribute Summary
Attributes inherited from BaseValidator
Instance Method Summary collapse
Methods inherited from BaseValidator
#allow_blank?, #custom_error_message, #default_error_message, #error_message_hash, #initialize, #schema_key, #user_answer, #valid?
Constructor Details
This class inherits a constructor from MetadataPresenter::BaseValidator
Instance Method Details
#invalid_answer? ⇒ Boolean
5 6 7 8 9 10 11 12 13 14 |
# File 'app/validators/metadata_presenter/date_validator.rb', line 5 def invalid_answer? Date.strptime( "#{user_answer.year}-#{user_answer.month}-#{user_answer.day}", '%Y-%m-%d' ) false rescue Date::Error true end |
#validation_value ⇒ Object
16 17 18 19 20 |
# File 'app/validators/metadata_presenter/date_validator.rb', line 16 def validation_value return unless schema_key.in?(DATE_STRING_VALIDATIONS) Date.parse(component.validation[schema_key]).strftime('%d %m %Y') end |