Class: MetadataPresenter::DateBeforeValidator

Inherits:
DateValidator show all
Defined in:
app/validators/metadata_presenter/date_before_validator.rb

Constant Summary

Constants inherited from DateValidator

MetadataPresenter::DateValidator::DATE_STRING_VALIDATIONS, MetadataPresenter::DateValidator::YEAR_LOWER_BOUND, MetadataPresenter::DateValidator::YEAR_UPPER_BOUND

Instance Attribute Summary

Attributes inherited from BaseValidator

#component, #page_answers

Instance Method Summary collapse

Methods inherited from DateValidator

#validation_value

Methods inherited from BaseValidator

#allow_blank?, #custom_error_message, #default_error_message, #error_key, #error_message_hash, #initialize, #schema_key, #user_answer, #valid?, #validation_value

Constructor Details

This class inherits a constructor from MetadataPresenter::BaseValidator

Instance Method Details

#invalid_answer?Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
# File 'app/validators/metadata_presenter/date_before_validator.rb', line 3

def invalid_answer?
  return if super

  answer_date = "#{user_answer.year}-#{user_answer.month}-#{user_answer.day}"
  Date.parse(answer_date).iso8601 > Date.parse(component.validation[schema_key]).iso8601
end