Class: EmailValidator

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

Overview

Custom validator checking for an email address

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object

:nodoc:



3
4
5
6
# File 'lib/atreides/validators.rb', line 3

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