Tyyppi.Example.Struct (tyyppi v0.7.0) View Source
Example of the structure defined with Tyyppi.Struct.defstruct/1
The original code of this module follows:
use Tyyppi
@typedoc "The user type defined before `defstruct/1` declaration"
@type my_type :: :ok | {:error, term()}
@defaults bar: {:ok, :erlang.list_to_pid('<0.0.0>')}, baz: {:error, :reason}
defstruct foo: nil | atom(), bar: GenServer.on_start(), baz: my_type()
Link to this section Summary
Functions
Returns the field types of this struct as keyword of
{field :: atom, type :: Tyyppi.T.t(term())}
pairs.
Updates the struct
This function is supposed to be overwritten in the implementation in cases when custom validation is required.
Link to this section Types
Specs
my_map_1() :: %{foo: atom()}
The user type exported
Specs
Specs
Specs
Specs
my_type() :: :ok | {:error, term()}
The user type defined before defstruct/1
declaration
Specs
t() :: %Tyyppi.Example.Struct{ foo: atom(), bar: GenServer.on_start(), baz: my_type() }
The type describing this struct. This type will be used to validate
upserts when called via Access
and/or Tyyppi.Example.Struct.put/3
,
Tyyppi.Example.Struct.update/4
.
Link to this section Functions
Specs
types() :: [{atom(), Tyyppi.T.t(wrapped)}] when wrapped: term()
Returns the field types of this struct as keyword of
{field :: atom, type :: Tyyppi.T.t(term())}
pairs.
Specs
Updates the struct
Specs
This function is supposed to be overwritten in the implementation in cases when custom validation is required.
It would be called after all casts and type validations, if the succeeded