Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add non-documented phone number verification IsValid allowed value #9

Merged
merged 1 commit into from Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/loqate/phone/phone_number_validation.rb
Expand Up @@ -2,7 +2,7 @@ module Loqate
module Phone
# Result of a phone number validation.
class PhoneNumberValidation < Dry::Struct
IsValid = Types::Strict::String.enum('Yes', 'No', 'Unknown')
IsValid = Types::Strict::String.enum('Yes', 'No', 'Unknown', 'Maybe')
NumberType = Types::Strict::String.enum('Mobile', 'Landline', 'Voip', 'Unknown')

# The recipient phone number in international format.
Expand Down
20 changes: 8 additions & 12 deletions spec/loqate/phone/phone_number_validation_spec.rb
Expand Up @@ -91,22 +91,18 @@
end

describe '#valid?' do
context 'when the validation result is Yes' do
subject { described_class.new(attributes.merge(is_valid: 'Yes')) }

it { is_expected.to be_valid }
end
%w[No Unknown Maybe].each do |validation_result|
context "when the validation result is '#{validation_result}'" do
subject { described_class.new(attributes.merge(is_valid: validation_result)) }

context 'when the validation result is No' do
subject { described_class.new(attributes.merge(is_valid: 'No')) }

it { is_expected.not_to be_valid }
it { is_expected.not_to be_valid }
end
end

context 'when the validation result is Unknown' do
subject { described_class.new(attributes.merge(is_valid: 'Unknown')) }
context 'when the validation result is Yes' do
subject { described_class.new(attributes.merge(is_valid: 'Yes')) }

it { is_expected.not_to be_valid }
it { is_expected.to be_valid }
end
end
end