Validex Build StatusCoverage StatusInline 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

License

Released under the MIT License.