Class: ActiveRecord::Validations::EmailValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



4
5
6
# File 'lib/active_record.rb', line 4

def validate_each(record, attribute, value)
  record.errors[attribute] << (options[:message] || 'is invalid') unless value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
end