Class: Sooner::EmailFormatValidator

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

Instance Method Summary collapse

Instance Method Details

#validate_each(object, attribute, value) ⇒ Object



3
4
5
6
7
# File 'lib/sooner/email_format_validator.rb', line 3

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