Class: MetadataPresenter::AddressValidator

Inherits:
BaseValidator show all
Defined in:
app/validators/metadata_presenter/address_validator.rb

Constant Summary collapse

REQUIRED_FIELDS =
%i[
  address_line_one
  city
  postcode
  country
].freeze
OPTIONAL_FIELDS =
%i[
  address_line_two
  county
].freeze

Instance Attribute Summary

Attributes inherited from BaseValidator

#component, #page_answers

Instance Method Summary collapse

Methods inherited from BaseValidator

#custom_error_message, #default_error_message, #error_key, #error_message_hash, #initialize, #invalid_answer?, #schema_key, #user_answer, #validation_value

Constructor Details

This class inherits a constructor from MetadataPresenter::BaseValidator

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'app/validators/metadata_presenter/address_validator.rb', line 15

def valid?
  return true if allow_blank?

  validate_required_fields

  user_answer.errors.empty?
end