Skip to content

validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696

License

Notifications You must be signed in to change notification settings

webhoernchen/validates_email

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

validates_email

validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696

Installation

rails plugin install git://github.com/spectator/validates_email.git

or

gem 'spectator-validates_email', :require => 'validates_email'

Usage

class User < ActiveRecord::Base
  validates :field, :email => true
end

As well as any other Rails 3 validation this one has the same triggers, such as :on, :if, :unless, :allow_blank, and :allow_nil.

Also, you can pass your custom error message, otherwise it will use ActiveRecord’s invalid error message.

class User < ActiveRecord::Base
  validates :field, :email => { :message => 'is not an email address' }
end

If you like to check MX Records for email, you can use :mx option.

class User < ActiveRecord::Base
  validates :field, :email => { :mx => true }
end

And if you like to check MX Records with fallback to A record, use :a_fallback option.

class User < ActiveRecord::Base
  validates :field, :email => { :mx => { :a_fallback => true } }
end

Testing

To execute unit tests run rake test within plugin folder.

The unit tests for this plugin use an in-memory sqlite3 database.

Credits

Most of the code were taken from Alex Dunae (dunae.ca) plugin (see github.com/alexdunae/validates_email_format_of/) and adopted for Rails 3, so pass all beers to him.

Contributors

Petr Blaho

Notes

Tested under ruby 1.9.2-rc1 and Rails 3 Edge

About

validates_email is a Rails 3 plugin that validates email addresses against RFC 2822 and RFC 3696

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%