<commit_before># ValidateAsEmail [![Build Status](https://secure.travis-ci.org/evently/validate_as_email.png?branch=master)](http://travis-ci.org/evently/validate_as_email) [![CodeClimate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/evently/validate_as_email)

Validation of email addresses via the excellent Mail gem that is
available in all Rails 3 applications.

## Installation

Add this line to your application's Gemfile:

    gem 'validate_as_email'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install validate_as_email

## Usage

This gem required Ruby 1.9, and is tested against MRI, JRuby, and
Rubinius using Travis CI.

You will need to be using Rails 3 to make use of this validator, as it
is built on top of ActiveModel, which was introduced in Rails 3.

### Usage with ActiveModel

``` ruby
class Person
  include ActiveModel::Validations
  validates_as_email :email
  attr_accessor :email
end

# OR

class Person
  include ActiveModel::Validations
  validates :email, email: true
  attr_accessor :email
end
```

### Usage with ActiveRecord

``` ruby
class Person < ActiveRecord::Base
  validates_as_email :email
  attr_accessor :email
end

# OR

class Person < ActiveRecord::Base
  validates :email, email: true
  attr_accessor :email
end
```

### Built-in RSpec Matcher

``` ruby
class Person < ActiveRecord::Base
  validates_as_email :email
  attr_accessor :email
end

describe Person do
  it { should have_a_valid_email_address_for(:email) }
  it { should_not have_a_valid_email_address_for(:email) }
end
```

## Contributing<commit_msg>Add a note about how to load RSpec matcher<commit_after># ValidateAsEmail [![Build Status](https://secure.travis-ci.org/evently/validate_as_email.png?branch=master)](http://travis-ci.org/evently/validate_as_email) [![CodeClimate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/evently/validate_as_email)

Validation of email addresses via the excellent Mail gem that is
available in all Rails 3 applications.

## Installation

Add this line to your application's Gemfile:

    gem 'validate_as_email'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install validate_as_email

## Usage

This gem required Ruby 1.9, and is tested against MRI, JRuby, and
Rubinius using Travis CI.

You will need to be using Rails 3 to make use of this validator, as it
is built on top of ActiveModel, which was introduced in Rails 3.

### Usage with ActiveModel

``` ruby
class Person
  include ActiveModel::Validations
  validates_as_email :email
  attr_accessor :email
end

# OR

class Person
  include ActiveModel::Validations
  validates :email, email: true
  attr_accessor :email
end
```

### Usage with ActiveRecord

``` ruby
class Person < ActiveRecord::Base
  validates_as_email :email
  attr_accessor :email
end

# OR

class Person < ActiveRecord::Base
  validates :email, email: true
  attr_accessor :email
end
```

### Built-in RSpec Matcher

The custom matcher will be loaded automatically if RSpec is loaded
first. Otherwise, you'll need to require the RSpec matcher manually
using `require 'validate_as_email/rspec'`.

``` ruby
require 'validate_as_email/rspec'

class Person < ActiveRecord::Base
  validates_as_email :email
  attr_accessor :email
end

describe Person do
  it { should have_a_valid_email_address_for(:email) }
  it { should_not have_a_valid_email_address_for(:email) }
end
```

## Contributing
{'fraction_non_alphanumeric': 0.08625180897250362, 'fraction_numerical': 0.002894356005788712, 'mean_word_length': 4.847715736040609, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '692115', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1067, 'n_words': 353}