Class: SpamEmailValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/spam_email.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



10
11
12
13
14
15
# File 'lib/spam_email.rb', line 10

def validate_each(record, attribute, value)
  if SpamEmail.blacklisted?(value)
    message = (options[:message] || I18n.t(:blacklisted, scope: 'spam_email.validations.email'))
    record.errors[attribute] << message
  end
end