Class: EmailInquire::Validator::CommonlyMistakenTld

Inherits:
Base
  • Object
show all
Defined in:
lib/email_inquire/validator/commonly_mistaken_tld.rb

Constant Summary collapse

MISTAKES =
{
  ".combr" => ".com.br",
  ".cojp" => ".co.jp",
  ".couk" => ".co.uk",
  ".com.com" => ".com",
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#domain, #email, #name

Instance Method Summary collapse

Methods inherited from Base

#initialize, validate

Constructor Details

This class inherits a constructor from EmailInquire::Validator::Base

Instance Method Details

#validateObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/email_inquire/validator/commonly_mistaken_tld.rb', line 16

def validate
  mistake, reference =
    MISTAKES.find do |mistake, reference|
      next if !mistake.end_with?(reference) && domain.end_with?(reference)

      domain.end_with?(mistake)
    end

  response.hint!(domain: domain.sub(/#{mistake}\z/, reference)) if reference
end