Giter Site home page Giter Site logo

xbacon's Introduction

bacon

xBacon

Build Status

A set of validators and matchers, focusing on Brazilian needs, but general too!

Here you can find useful validations for your changeset, or just matchers if you want!

How do I use it ?

Simply import the changeset module into your model and pipe the validations on your changeset!

defmodule App.Person do
  import XBacon.Changeset.CPF

  # ....

  def changeset(model, params \\ %{}) do
    model
    |> cast(params, @fields)
    |> validate_required(@req_fields)
    |> validate_cpf
  end
end

The validators use a default field naming matching the subject being validated, for example, if you are validating CPF with validate_cpf/2 you can provide an atom as second arity if your field is not named :cpf

Installation

The package can be installed as:

  1. Add xbacon to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:xbacon, "~> 0.1.0"}]
end
```
  1. Ensure xbacon is started before your application:
```elixir
def application do
  [applications: [:xbacon]]
end
```

Icons made by Freepick

xbacon's People

Contributors

theevangelista avatar

xbacon's Issues

RG validation

Since each state has it rules for verification, it should only verify if has only digits at a required size

CEP validation

CEP as part of an address should be validated since most of address rely on it to find all address information automatic.

The most common pattern for CEP is 000000-000, so in regex it could be [0-9]{5}[-]?[0-9]{3}.
This will allow both previous format and plain 00000000 formart

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.