Module: ValidateEmailAddress

Included in:
ActiveRecord::Base
Defined in:
lib/method.rb

Instance Method Summary collapse

Instance Method Details

#validates_email_address_of(attr_name) ⇒ Object



3
4
5
6
7
8
# File 'lib/method.rb', line 3

def validates_email_address_of attr_name
  email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  self.validates_format_of attr_name, 
                           :with => email_regex, 
                           :message => "is not a valid email address"
end