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", street_name: "street_name", street_number: "street_number", neighborhood: "neighborhood", line2: "line2", 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.
-
#message_format ⇒ Object
readonly
Returns the value of attribute message_format.
-
#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.
-
#unsupported_fields ⇒ Object
readonly
Returns the value of attribute unsupported_fields.
-
#zip ⇒ Object
readonly
Returns the value of attribute zip.
Instance Method Summary collapse
- #build_fields ⇒ Object
-
#initialize(address:, matching_strategy:, locale: "en", context: {}, message_format: MessageFormat::Instructional) ⇒ Validator
constructor
A new instance of Validator.
- #run ⇒ Object
Constructor Details
#initialize(address:, matching_strategy:, locale: "en", context: {}, message_format: MessageFormat::Instructional) ⇒ Validator
Returns a new instance of Validator.
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 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 63 def initialize( address:, matching_strategy:, locale: "en", context: {}, message_format: MessageFormat::Instructional ) @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) @message_format = T.let(, MessageFormat) matching_strategy_name = matching_strategy.serialize @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, ) pipeline_builder = PredicatePipelineBuilder.new(matching_strategy_name:, address:, result:, message_format:) @pipeline = T.let( pipeline_builder.pipeline, T::Array[AtlasEngine::AddressValidation::PredicatePipeline::PredicateConfig], ) @unsupported_fields = T.let(pipeline_builder.unsupported_fields, T::Array[Symbol]) @full_address_validator = T.let(pipeline_builder.full_address_validator, 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 |
#message_format ⇒ Object (readonly)
Returns the value of attribute message_format.
35 36 37 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 35 def @message_format 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 |
#unsupported_fields ⇒ Object (readonly)
Returns the value of attribute unsupported_fields.
32 33 34 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 32 def unsupported_fields @unsupported_fields 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
115 116 117 118 119 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 115 def build_fields result.fields = address.keys.map do |field| Field.new(name: field, value: address[field]) end end |
#run ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'app/models/atlas_engine/address_validation/validator.rb', line 104 def run build_fields populate_result(execute_pipeline) validate_full_address result end |