View Source Litmus (litmus v1.0.2)

Litmus is a data validation library for Elixir.

Link to this section Summary

Functions

Validates and converts data based on a schema.

Link to this section Functions

Specs

validate(map(), map()) :: {:ok, map()} | {:error, String.t()}

Validates and converts data based on a schema.

examples

Examples

iex> Litmus.validate(%{"id" => "123"}, %{"id" => %Litmus.Type.Number{}})
{:ok, %{"id" => 123}}

iex> Litmus.validate(%{"id" => "asdf"}, %{"id" => %Litmus.Type.Number{}})
{:error, "id must be a number"}