A RFC compliant Email validator

Compliant to the rfc 5322 standard.

Installation

gem install ruby_email

or in the Gemfile

gem 'ruby_email'

 Usage in Ruby

require 'ruby_email'

"local@domain".is_email? # => true
RubyEmail.validates? "toto@tata" # => true
RubyEmail.match "toto@tata" # => #<MatchData "toto@tata" local:"toto" domain:"tata">
"local".is_email? # => false
RubyEmail.validates? "toto" # => false
RubyEmail.match "toto" # => nil

"[email protected]".is_public_email? # => true
"local@domain".is_public_email? # => false
RubyEmail::Public.validates? "[email protected]" # => true
RubyEmail::Public.match "[email protected]" # => #<MatchData "toto@tata" local:"toto" domain:"tata.com">

Usage in Ruby on Rails

class Model < ActiveRecord::Base
  # validates :email, format: RubyEmail::REGEXP # valid on an intranet ...
  validates :email, format: RubyEmail::Public::REGEXP
end

Unitary tests

rake test

Contributes !

Find a bug ? Want a new feature ? Create a clear pull request and we'll see :)

  • Nephos (poulet_a)