Class: AtlasEngine::AddressValidation::Validators::FullAddress::InvalidZipForCountryConcernBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
ConcernFormatter
Defined in:
app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_country_concern_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConcernFormatter

#country_name, #province_name

Constructor Details

#initialize(address, message_format) ⇒ InvalidZipForCountryConcernBuilder

Returns a new instance of InvalidZipForCountryConcernBuilder.



15
16
17
18
# File 'app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_country_concern_builder.rb', line 15

def initialize(address, message_format)
  @address = address
  @message_format = message_format
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



11
12
13
# File 'app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_country_concern_builder.rb', line 11

def address
  @address
end

#message_formatObject (readonly)

Returns the value of attribute message_format.



12
13
14
# File 'app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_country_concern_builder.rb', line 12

def message_format
  @message_format
end

Instance Method Details

#build(suggestion_ids = []) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_for_country_concern_builder.rb', line 21

def build(suggestion_ids = [])
  message = country.field(key: :zip).error(
    code: "invalid_for_country_#{message_format.serialize}".to_sym,
    options: { country: country.full_name },
  ).to_s

  Concern.new(
    code: :zip_invalid_for_country,
    field_names: [:zip],
    message: message,
    type: T.must(Concern::TYPES[:error]),
    type_level: 1,
    suggestion_ids: suggestion_ids,
  )
end