Class: EmailValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/spree/core/validators/email.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/spree/core/validators/email.rb', line 2

def validate_each(record, attribute, value)
  unless value =~ %r{\A(([A-Za-z0-9]+_+)|
                        ([A-Za-z0-9]+\-+)|
                        ([A-Za-z0-9]+\.+)|
                        ([A-Za-z0-9]+\++))*[A-Za-z0-9_]+@((\w+\-+)|
                        (\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}\z}xi
    record.errors.add(attribute, :invalid, { value: value }.merge!(options))
  end
end