Class: AtlasEngine::Gg::AddressValidation::Validators::FullAddress::Restrictions::UnsupportedCity

Inherits:
Object
  • Object
show all
Extended by:
Restrictions::Base, T::Sig
Defined in:
app/countries/atlas_engine/gg/address_validation/validators/full_address/restrictions/unsupported_city.rb

Constant Summary collapse

UNSUPPORTED_CITY_ZIP_MAPPING =
{
  "SARK" => "GY9",
  "ALDERNEY" => "GY10",
}.freeze

Class Method Summary collapse

Methods included from Restrictions::Base

apply?

Class Method Details

.apply?(address:, params: nil) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'app/countries/atlas_engine/gg/address_validation/validators/full_address/restrictions/unsupported_city.rb', line 26

def apply?(address:, params: nil)
  zip_prefix = UNSUPPORTED_CITY_ZIP_MAPPING[address.city&.upcase]
  return false if zip_prefix.nil?

  address.zip&.start_with?(zip_prefix).present?
end