Skip to content
/ validex Public

Validex is a library for doing data validation in Elixir.

Notifications You must be signed in to change notification settings

lixhq/validex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Validex Build Status Coverage Status Inline docs

Validex is a library for doing data validation in Elixir.

At Lix we use it to ensure all data entering our domain is fully validated. One goal of Validex is to make schema definitions easy to read and write using intuitive syntax.

Validex is easily extendable and allow you to specify custom validators by implementing the Validex.Validator behaviour. Another extensionpoint is custom Validex.RuleExpander, that allow for rewriting the schema in order to have custom shorthands for a larger schema. One example of this can be seen here.

Installation

The package can be installed by adding validex to your list of dependencies in mix.exs:

def deps do
  [{:validex, "~> 0.1"}]
end

Usage

schema = [name: :string, age: :integer, sex: :atom]
data = %{ name: "Simon", age: :ripe }

false = Validex.valid?(data, schema)

[
  {:error, :age, :type, "age should be integer but was atom" },
  {:error, :sex, :presence, "sex is a required attribute but was absent"}
] = Validex.errors(data, schema)

Documentation

Documentation can be found at https://hexdocs.pm/validex.

Prior art

  • PropTypex which were the previous library we wrote for doing data validation.
  • Vex A now abandoned validation library by the people behind Absinthe.

License

Released under the MIT License.

About

Validex is a library for doing data validation in Elixir.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages