Class: EmailInquire::Validator::CommonProviderMistake

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

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



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/email_inquire/validator/common_provider_mistake.rb', line 11

def validate
  return if CommonProvider::DOMAINS.include?(domain)

  replacement_domain =
    CommonProvider::DOMAINS.find do |reference|
      distance = DamerauLevenshtein.distance(domain, reference)

      distance.equal?(1)
    end

  response.hint!(domain: replacement_domain) if replacement_domain
end