Skip to content

theevangelista/xbacon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages