Code Monkey home page Code Monkey logo

synapses-validators's Introduction

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.

synapses-validators's People

Stargazers

João Lucas Pereira de Santana avatar Synapses Group avatar

Watchers

Renato Ferraz avatar James Cloos avatar João Lucas Pereira de Santana avatar Jônatas avatar Synapses Group avatar Tiago Machado avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.