Skip to content

synapsesgroup/synapses-validators

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages