Class: EmailValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
app/validators/email_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



7
8
9
10
11
12
# File 'app/validators/email_validator.rb', line 7

def validate_each(record, attribute, value)
  return if options[:allow_nil] && value.nil?
  return if options[:allow_blank] && value.blank?

  record.errors.add(attribute, :invalid, options) unless valid_format?(value) && valid_dns?(value)
end