Class: EmailValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- EmailValidator
- Defined in:
- lib/email_assessor/email_validator.rb
Instance Method Summary collapse
Instance Method Details
#default_options ⇒ Object
7 8 9 |
# File 'lib/email_assessor/email_validator.rb', line 7 def { regex: true, disposable: false, mx: false, fastpass: true } end |
#validate_each(record, attribute, value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/email_assessor/email_validator.rb', line 11 def validate_each(record, attribute, value) return unless value.present? = .merge!(self.) address = EmailAssessor::Address.new(value) error(record, attribute) && return unless address.valid? # Skip all domain blocklist checks for fastpass domains. # The goal is to skip needless validation for common "good" domains such as Gmail, Yahoo, and Outlook. # The fastpass domain list is configurable via vendor/fastpass_domains.txt validate_domain(record, attribute, address, ) unless [:fastpass] && address.fastpass? # Exit early if validate_domain found a validation error return if record.errors.key?(attribute) if [:mx] error(record, attribute, error_type(:mx, )) && return unless address.valid_mx? end end |