Codex.Validator.Norm (codex v0.9.2) View Source
Validator using Norm
Adds schema and gen functions on the Codex module.
schema/0 returns Norm schema of the module
gen/0 returns StreamData generator based on schema
Example
defmodule NormCodex do
use Codex
params schema(%{
name: spec(is_binary())
})
def call(args, _) do
{:ok, args |> Map.put(:b, 2)}
end
end
iex> NormCodex.schema
#Norm.Schema<%{name: #Norm.Spec<is_binary()>}>
iex> NormCodex.gen |> Enum.take(3)
[%{name: "_"}, %{name: ""}, %{name: <<191, 134, 10>>}]