Class: Loqate::Phone::PhoneNumberValidation

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/loqate/phone/phone_number_validation.rb

Overview

Result of a phone number validation.

Constant Summary collapse

IsValid =
Types::Strict::String.enum('Yes', 'No', 'Unknown')
NumberType =
Types::Strict::String.enum('Mobile', 'Landline', 'Voip', 'Unknown')

Instance Method Summary collapse

Instance Method Details

#country_prefixInteger

The country prefix that must be prepended to the number when dialling internationally.

Returns:

  • (Integer)


55
# File 'lib/loqate/phone/phone_number_validation.rb', line 55

attribute :country_prefix, Types::Coercible::Integer

#is_validString

Whether the number is valid or not (Unknown returned if validation wasn’t possible).

Returns:

  • (String)


25
# File 'lib/loqate/phone/phone_number_validation.rb', line 25

attribute :is_valid, IsValid

#national_formatString

The domestic network format (useful for dialling from within the same country).

Returns:

  • (String)


49
# File 'lib/loqate/phone/phone_number_validation.rb', line 49

attribute :national_format, Types::Strict::String

#network_codeString

The current operator serving the supplied number.

Returns:

  • (String)


31
# File 'lib/loqate/phone/phone_number_validation.rb', line 31

attribute :network_code, Types::Strict::String

#network_countryString

The country code of the operator.

Returns:

  • (String)


43
# File 'lib/loqate/phone/phone_number_validation.rb', line 43

attribute :network_country, Types::Strict::String

#network_nameString

The name of the current operator serving the supplied number.

Returns:

  • (String)


37
# File 'lib/loqate/phone/phone_number_validation.rb', line 37

attribute :network_name, Types::Strict::String

#number_typeString

The type of number that was detected in the request (Mobile, Landline, VOIP or Unknown).

Returns:

  • (String)


61
# File 'lib/loqate/phone/phone_number_validation.rb', line 61

attribute :number_type, NumberType

#phone_numberString

The recipient phone number in international format.

Returns:

  • (String)


12
# File 'lib/loqate/phone/phone_number_validation.rb', line 12

attribute :phone_number, Types::Strict::String

#request_processedBoolean

Returns true if we managed to process the request on the network or false if the validation attempt was unsuccessful.

Returns:

  • (Boolean)


19
# File 'lib/loqate/phone/phone_number_validation.rb', line 19

attribute :request_processed, Types::Strict::Bool

#valid?Boolean

Whether the validation was successful or not.

Returns:

  • (Boolean)


64
65
66
# File 'lib/loqate/phone/phone_number_validation.rb', line 64

def valid?
  is_valid == 'Yes'
end