Sha256: b67bffff948d249d8413d95b44bb394bda22cacd58e886580371d0564a470053
Contents?: true
Size: 1.1 KB
Versions: 16
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Truemail module Validate class ListMatch < Truemail::Validate::Base ERROR = 'blacklisted email' def run return success(true) if whitelisted? && !whitelist_validation? return unless whitelist_validation_case? || blacklisted? success(false) add_error(Truemail::Validate::ListMatch::ERROR) end private def email @email ||= result.email end def email_domain @email_domain ||= result.domain = email[Truemail::RegexConstant::REGEX_DOMAIN_FROM_EMAIL, 1] end def whitelisted? configuration.whitelisted_emails.include?(email) || configuration.whitelisted_domains.include?(email_domain) end def whitelist_validation? configuration.whitelist_validation end def whitelist_validation_case? whitelist_validation? && !whitelisted? end def blacklisted? configuration.blacklisted_emails.include?(email) || configuration.blacklisted_domains.include?(email_domain) end end end end
Version data entries
16 entries across 16 versions & 1 rubygems