Class: AtlasEngine::AddressValidation::Validators::FullAddress::ZipComparison
- Inherits:
-
FieldComparisonBase
- Object
- FieldComparisonBase
- AtlasEngine::AddressValidation::Validators::FullAddress::ZipComparison
show all
- Extended by:
- T::Sig
- Defined in:
- app/models/atlas_engine/address_validation/validators/full_address/zip_comparison.rb
Instance Attribute Summary
#component
Instance Method Summary
collapse
#initialize, #match?
Instance Method Details
#relevant? ⇒ Boolean
12
13
14
|
# File 'app/models/atlas_engine/address_validation/validators/full_address/zip_comparison.rb', line 12
def relevant?
true
end
|
#sequence_comparison ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/models/atlas_engine/address_validation/validators/full_address/zip_comparison.rb', line 17
def sequence_comparison
return @zip_comparison if defined?(@zip_comparison)
candidate.component(:zip)&.value = PostalCodeMatcher.new(
T.must(address.country_code),
T.must(address.zip),
candidate.component(:zip)&.value,
).truncate
normalized_zip = ValidationTranscriber::ZipNormalizer.normalize(
country_code: address.country_code, zip: address.zip,
)
zip_sequence = Token::Sequence.from_string(normalized_zip)
@zip_comparison = best_comparison(
zip_sequence,
T.must(candidate.component(:zip)).sequences,
field_policy(:zip),
)
end
|