View Source Veli.Build (Veli v0.2.7)

This macro allows you define rule and add a validator function inside of it.

defmodule Validators.Users do
  use Veli.Build, %Veli.Types.Map{
    rule: %{
      "username" => [type: :string, min: 3, max: 32],
      "age" => [type: :integer, min: 13]
    },
    strict: true
  }
end

Validators.Users.valid(%{"username" => "hello", "age" => 17})
|> Veli.error