Skip to content

fourkio/validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

validator

Build Status

This is aims to be an elixir clone of the NPM Validator package.

Currently, only UUIDs, emails and URLs are supported.

Installation

If available in Hex, the package can be installed as:

  1. Add validator to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:validator, "~> 0.2.0"}]
end
```
  1. Run mix deps.install

  2. Ensure validator is started before your application:

```elixir
def application do
  [applications: [:validator]]
end
```

Usage

  def changeset(struct, params \\ %{}) do
    struct
    |> cast(params, [:api_id, :some_url, :some_email])
    |> validate_required([:api_id, :some_url])
    |> Validator.validate_uuid(:api_id)
    |> Validator.validate_email(:some_email)
    |> Validator.validate_url(:some_url)
  end

About

A set of format validators for elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages