Class: Loqate::Email::EmailValidation

Inherits:
Dry::Struct::Value
  • Object
show all
Defined in:
lib/loqate/email/email_validation.rb

Overview

Result of a email address validation.

Constant Summary collapse

ResponseCode =
Types::Strict::String.enum('Valid', 'Valid_CatchAll', 'Invalid', 'Timeout')

Instance Method Summary collapse

Instance Method Details

#domainString

The domain portion of the email address provided.

Returns:

  • (String)


38
# File 'lib/loqate/email/email_validation.rb', line 38

attribute :domain, Types::Strict::String

#durationFloat

The duration (in seconds) that the email validation took (maximum timeout enforced at 15 seconds). We recommend a high timeout (at least 5 seconds) value as it will minimise the number of “Timeout” responses returned.

Returns:

  • (Float)


60
# File 'lib/loqate/email/email_validation.rb', line 60

attribute :duration, Types::Strict::Float

#email_addressString

The email address that verification was attempted on.

Returns:

  • (String)


26
# File 'lib/loqate/email/email_validation.rb', line 26

attribute :email_address, Types::Strict::String

#invalid?Boolean

Whether the email is invalid and shouldn’t be accepted.

Returns:

  • (Boolean)


73
74
75
# File 'lib/loqate/email/email_validation.rb', line 73

def invalid?
  response_code == 'Invalid'
end

#is_complainer_or_fraud_riskBoolean

True if we recognise the email address against known lists of complainers and/or the email address has been used to defraud.

Returns:

  • (Boolean)


52
# File 'lib/loqate/email/email_validation.rb', line 52

attribute :is_complainer_or_fraud_risk, Types::Strict::Bool

#is_disposable_or_temporaryBoolean

Whether the email address provided is a disposable mailbox (some companies create temporary mailboxes which shouldn’t be used for marketing communications).

Returns:

  • (Boolean)


45
# File 'lib/loqate/email/email_validation.rb', line 45

attribute :is_disposable_or_temporary, Types::Strict::Bool

#response_code'Valid', ...

Valid - The email address has been fully validated (including the account portion) Valid_CatchAll - The domain has been validated but the account could not be validated Invalid - The email address is invalid and shouldn’t be accepted Timeout - The validation could not be completed within the timeout specified (try increasing the timeout value)

Returns:

  • ('Valid', 'Valid_CatchAll', 'Invalid', 'Timeout')


14
# File 'lib/loqate/email/email_validation.rb', line 14

attribute :response_code, ResponseCode

#response_messageString

A textual description of the ResponseCode returned

Returns:

  • (String)


20
# File 'lib/loqate/email/email_validation.rb', line 20

attribute :response_message, Types::Strict::String

#timeout?Boolean

Whether the validation could not be completed within the timeout specified.

Returns:

  • (Boolean)


78
79
80
# File 'lib/loqate/email/email_validation.rb', line 78

def timeout?
  response_code == 'Timeout'
end

#user_accountString

The account portion of the email address provided.

Returns:

  • (String)

    String



32
# File 'lib/loqate/email/email_validation.rb', line 32

attribute :user_account, Types::Strict::String

#valid?Boolean

Whether the email was fully validated (including the account portion).

Returns:

  • (Boolean)


63
64
65
# File 'lib/loqate/email/email_validation.rb', line 63

def valid?
  response_code == 'Valid'
end

#valid_domain?Boolean

Whether the domain has been validated but the account hasn’t.

Returns:

  • (Boolean)


68
69
70
# File 'lib/loqate/email/email_validation.rb', line 68

def valid_domain?
  response_code == 'Valid' || response_code == 'Valid_CatchAll'
end