19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'app/models/atlas_engine/address_validation/validators/full_address/invalid_zip_concern_builder.rb', line 19
def for(address, suggestion_ids, message_format)
country = Worldwide.region(code: address.country_code)
province = country.zone(code: address.province_code.presence || "")
return unless country.has_zip?
if country_expects_zone_in_address?(country) && province.province?
return if province.valid_zip?(address.zip)
InvalidZipForProvinceConcernBuilder.new(address, message_format).build
else
return if country.valid_zip?(address.zip)
InvalidZipForCountryConcernBuilder.new(address, message_format).build(suggestion_ids)
end
end
|