Confispex.Type behaviour (confispex v1.1.0)
Link to this section Summary
Functions
Cast input
using type in type_reference()
Link to this section Types
Link to this type
error_details()
Specs
error_details() :: [ String.t() | error_details() | {:highlight | :validation | :parsing, error_details()} | {:nested, [error_details()]} ]
Link to this type
type_reference()
Specs
Link to this section Callbacks
Link to this callback
cast(value, opts)
Specs
cast(value :: term(), opts :: Keyword.t()) :: {:ok, value :: term()} | :error | {:error, error_details()}
Link to this section Functions
Link to this function
cast(value, type)
Specs
cast(input :: any(), type_reference()) :: {:ok, output :: any()} | {:error, {failed_on_value :: any(), type_reference(), error_details()}}
Cast input
using type in type_reference()
Examples
iex> Confispex.Type.cast("dev", {Confispex.Type.Enum, values: [:prod, :test, :dev]})
{:ok, "dev"}
iex> Confispex.Type.cast("prodd", {Confispex.Type.Enum, values: [:prod, :test, :dev]})
{:error,
{"prodd", {Confispex.Type.Enum, [values: [:prod, :test, :dev]]},
[
validation: [
"expected one of: ",
[
{:highlight, "prod"},
", ",
{:highlight, "test"},
", ",
{:highlight, "dev"}
]
]
]}}