Class: AtlasEngine::AddressValidation::Validator
- Inherits:
-
Object
- Object
- AtlasEngine::AddressValidation::Validator
- Extended by:
- T::Sig
- Includes:
- RunsValidation
- Defined in:
- app/models/atlas_engine/address_validation/validator.rb
Constant Summary collapse
- FIELD_MAP =
T.let( { country: "country_code", province: "province_code", zip: "zip", city: "city", address1: "address1", address2: "address2", phone: "phone", }, T::Hash[Symbol, String], )
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#address1 ⇒ Object
readonly
Returns the value of attribute address1.
-
#address2 ⇒ Object
readonly
Returns the value of attribute address2.
-
#city ⇒ Object
readonly
Returns the value of attribute city.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#country_code ⇒ Object
readonly
Returns the value of attribute country_code.
-
#full_address_validator ⇒ Object
readonly
Returns the value of attribute full_address_validator.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#province_code ⇒ Object
readonly
Returns the value of attribute province_code.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Instance Method Summary collapse
- #build_fields ⇒ Object
-
#initialize(address:, matching_strategy:, locale: "en", context: {}) ⇒ Validator
constructor
A new instance of Validator.
- #run ⇒ Object
Constructor Details
#initialize(address:, matching_strategy:, locale: "en", context: {}) ⇒ Validator
Returns a new instance of Validator.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 52 def initialize( address:, matching_strategy:, locale: "en", context: {} ) @address = T.let(address, AbstractAddress) @address1 = T.let(address.address1, T.nilable(String)) @address2 = T.let(address.address2, T.nilable(String)) @city = T.let(address.city, T.nilable(String)) @province_code = T.let(address.province_code, T.nilable(String)) @phone = T.let(address.phone, T.nilable(String)) @zip = T.let(address.zip, T.nilable(String)) @country_code = T.let(address.country_code, T.nilable(String)) @context = T.let(context, T::Hash[T.untyped, T.untyped]) @matching_strategy = T.let(matching_strategy, Strategies) matching_strategy_name = matching_strategy.serialize @predicate_pipeline = T.let(PredicatePipeline.find(matching_strategy_name), PredicatePipeline) @result = T.let( Result.new( client_request_id: context.dig(:client_request_id), origin: context.dig(:origin), locale: locale, matching_strategy: matching_strategy_name, ), Result, ) @full_address_validator = T.let( @predicate_pipeline.full_address_validator&.new( address: @address, result: @result, ), T.nilable(FullAddressValidatorBase), ) end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
23 24 25 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 23 def address @address end |
#address1 ⇒ Object (readonly)
Returns the value of attribute address1.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 11 def address1 @address1 end |
#address2 ⇒ Object (readonly)
Returns the value of attribute address2.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 11 def address2 @address2 end |
#city ⇒ Object (readonly)
Returns the value of attribute city.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 11 def city @city end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
26 27 28 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 26 def context @context end |
#country_code ⇒ Object (readonly)
Returns the value of attribute country_code.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 11 def country_code @country_code end |
#full_address_validator ⇒ Object (readonly)
Returns the value of attribute full_address_validator.
29 30 31 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 29 def full_address_validator @full_address_validator end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 11 def phone @phone end |
#province_code ⇒ Object (readonly)
Returns the value of attribute province_code.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 11 def province_code @province_code end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
20 21 22 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 20 def result @result end |
#zip ⇒ Object (readonly)
Returns the value of attribute zip.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 11 def zip @zip end |
Instance Method Details
#build_fields ⇒ Object
103 104 105 106 107 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 103 def build_fields result.fields = address.keys.map do |field| Field.new(name: field, value: address[field]) end end |
#run ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 92 def run build_fields populate_result(execute_pipeline) validate_full_address result end |