Xema.ValidationError.travers_errors
You're seeing just the function
travers_errors
, go back to Xema.ValidationError module for more information.
Specs
travers_errors( {:error, map()} | map(), acc, (map(), path(), acc -> acc), opts() ) :: acc when acc: any()
Traverse the error tree and invokes the given function.
Example
iex> fun = fn _error, path, acc ->
...> ["Error at " <> inspect(path) | acc]
...> end
iex>
iex> schema = Xema.new(
...> properties: %{
...> int: :integer,
...> names: {:list, items: :string},
...> num: [any_of: [:integer, :float]]
...> }
...> )
iex>
iex> data = %{int: "x", names: [1, "x", 5], num: :foo}
iex>
iex> schema
...> |> Xema.Validator.validate(data)
...> |> Xema.ValidationError.travers_errors([], fun)
[
"Error at [:num]",
"Error at [:names, 2]",
"Error at [:names, 0]",
"Error at [:names]",
"Error at [:int]",
"Error at []"
]