No commit activity in last 3 years
No release in over 3 years
Adds CPF, CNPJ and Email validation
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Synapses Validators

Authors

Based on Brazilian Rails (https://github.com/tapajos/brazilian-rails)

How to use

Include "synapses-validators" in yor gemfile.

gem 'synapses-validators'

Go to your models, and set your validators.

CPF

validates :cpf, :presence => true, :uniqueness => true, :cpf => true, :if => :is_person_br?

Or

act_as_cpf :cpf

CNPJ

validates :cnpj, :presence => true, :uniqueness => true, :cnpj => true, :if => :is_business_br?

Or

act_as_cnpj :cpf

Email

  validates :email,
            :presence => true,
            :uniqueness => true,
            :length => {:within => 5..50},
            :email_format => true

I18n

The error messages is localized. So, you must have this lines in your locale files:

  activerecord:
    errors:
      messages:
        invalid: inválido
        not_formatted: não está no formato correto

TODO

  • Implement tests.

License

Synapses Validators is licensed for use under the terms of the MIT License.