MoreValidators
Rails gem/plugin is a series of validators provided by me or other people:
ValidateAsEmail: github.com/gbdev/validates_as_email
It’s released under Creative Commons Attribution-Share Alike 3.0 Unported License.
Talk to me if you have any questions: Rafael Barbolo: [email protected] twitter.com/barbolo
Installation:
Install the gem(s): gem install more_validators
Add to environment.rb initializer block: config.gem ‘more_validators’, :version => ‘>=0.1.0’, :lib => ‘validates_as_’
Usage:
In your model file do something like:
class MyClass < ActiveRecord::Base
# Email validation validates_as_email :email, :message => ‘Invalid’, :allow_nil => true # Brazilian postal code validation validates_as_cep :cep, :message => ‘Invalid’, :allow_nil => true # Brazilian phone number validation validates_as_phonenumber_br :phonenumber, :message => ‘Invalid’, :allow_nil => true # CPF validation validates_as_cpf :cpf, :message => ‘Invalid’, :allow_nil => true # CNPJ validation validates_as_cnpj :cnpj, :message => ‘Invalid’, :allow_nil => true
end
Tests:
Some tests have been added to each validator.
License:
See the LICENSE file.