ValidateCpf
Para ler esta documentação em português click aqui.
Adds CPF validation support to Rails (ActiveModel) and test it in a simple way.
Installation
Add this line to your application's Gemfile:
gem 'validate_cpf'
And then execute:
$ bundle
Or install it yourself as:
$ gem install validate_cpf
Usage
Just use as any other validator:
class User < ActiveRecord::Base
validates :cpf, cpf: true
end
Error Message
If you need to localize the error message, just add this to your I18n locale file:
errors:
messages:
this_document_is_invalid: "This document is invalid"
You can provide your own message using :message option.
validates :cpf, cpf: {message: "new error message"}
Mantainers
Contributors
To see the generous people who have contributed code, take a look at the contributors list.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
The gem is available as open source under the terms of the MIT License.