<commit_before># Validates

[![Build Status](https://travis-ci.org/kaize/validates.png)](https://travis-ci.org/kaize/validates)

Simple format validators for Rails 3

## Installation

Add this line to your application's Gemfile:

    gem 'validates'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install 'validates'

## Usage

Availables validators: AssociationLength, Email, Existence, Slug, Url, Money

    model User < ActiveRecord::Base
      validates :email, :email => true
      validates :site, :url => true, :allow_blank => true
      validates :inn, :inn => true   
    end

    model Company < ActiveRecord::Base
      # note AssociationLengthValidator is inherited from ActiveModel::Validations::LengthValidator
      # http://api.rubyonrails.org/classes/ActiveModel/Validations/LengthValidator.html
      # so you can easily use standard options like :is, :minimum, :maximum, etc.

      validates :employees,
        :association_length => {
          :minimum => 1,
          :select => ->(employee) { employee.name.in? ["Mike", "John"] }
        }

      validates :employees, :association_length => { :minimum => 1, :select => :employees_filter }

      def employees_filter(employees)
        employees.select { |employee| employee.name.in? ["Mike", "John"] }
      end
    end

    model Page < ActiveRecord::Base
      validates :slug, :slug => true
    end

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

run tests:
<commit_msg>typo fix<commit_after># Validates

[![Build Status](https://travis-ci.org/kaize/validates.png)](https://travis-ci.org/kaize/validates)

Simple format validators for Rails 3

## Installation

Add this line to your application's Gemfile:

    gem 'validates'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install 'validates'

## Usage

Availables validators: AssociationLength, Email, Existence, Slug, Url, Money

    class User < ActiveRecord::Base
      validates :email, :email => true
      validates :site, :url => true, :allow_blank => true
      validates :inn, :inn => true   
    end

    class Company < ActiveRecord::Base
      # note AssociationLengthValidator is inherited from ActiveModel::Validations::LengthValidator
      # http://api.rubyonrails.org/classes/ActiveModel/Validations/LengthValidator.html
      # so you can easily use standard options like :is, :minimum, :maximum, etc.

      validates :employees,
        :association_length => {
          :minimum => 1,
          :select => ->(employee) { employee.name.in? ["Mike", "John"] }
        }

      validates :employees, :association_length => { :minimum => 1, :select => :employees_filter }

      def employees_filter(employees)
        employees.select { |employee| employee.name.in? ["Mike", "John"] }
      end
    end

    class Page < ActiveRecord::Base
      validates :slug, :slug => true
    end

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

run tests:

{'fraction_non_alphanumeric': 0.11701170117011701, 'fraction_numerical': 0.004800480048004801, 'mean_word_length': 3.230964467005076, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 4, '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': '6212191', 'n_tokens_mistral': 1035, 'n_tokens_neox': 976, 'n_words': 309}