Schema validator inspired by Joi.
Add mayo to mix.exs
dependencies.
defp deps do
[{:mayo, "~> 0.1.0"}]
end
Download the dependencies.
$ mix deps.get
defmodule MyModule do
require Mayo
def call do
Mayo.validate %{
username: "John",
password: "1234"
}, %{
username: Mayo.Any.string |> Mayo.String.min(4),
password: Mayo.Any.string |> Mayo.String.min(6)
}
# {:error, %Mayo.Error{type: "string.min", paths: [:password]}}
end
end