View Source Tyyppi.Example.Nested (tyyppi v0.12.3)
Example of the nested structure defined with Tyyppi.Struct.defstruct/1
The code of this module follows.
use Tyyppi
@defaults date_time: Value.date_time("1973-09-30 02:30:00Z"),
struct: %Tyyppi.Example.Value{}
defstruct date_time: Value.t(DateTime.t()),
struct: Tyyppi.Example.Value.t()
Link to this section Summary
Types
The type describing Tyyppi.Example.Nested
. This type will be used to validate
upserts when called via Access
and/or Tyyppi.Struct.put/3
,
Tyyppi.Struct.update/3
, both delegating to generated
Tyyppi.Example.Nested.update/2
.
Functions
Factory for Elixir.Tyyppi.Example.Nested
wrapped by Tyyppi.Value
See Tyyppi.Struct.flatten/1
.
See Tyyppi.Struct.flatten/2
.
Helper guard to match instances of struct Tyyppi.Value
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
@type t() :: %Tyyppi.Example.Nested{ date_time: Tyyppi.Value.t(DateTime.t()), struct: Tyyppi.Example.Value.t() }
The type describing Tyyppi.Example.Nested
. This type will be used to validate
upserts when called via Access
and/or Tyyppi.Struct.put/3
,
Tyyppi.Struct.update/3
, both delegating to generated
Tyyppi.Example.Nested.update/2
.
Upon insertion, the value will be coerced to the expected type when available, the type itself will be validated, and then the custom validation will be applied when applicable.
Link to this section Functions
@spec as_value(keyword()) :: Tyyppi.Value.t({:any, [], []})
Factory for Elixir.Tyyppi.Example.Nested
wrapped by Tyyppi.Value
See Tyyppi.Struct.flatten/1
.
See Tyyppi.Struct.flatten/2
.
Helper guard to match instances of struct Tyyppi.Value
@spec 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.
Updates the struct
@spec validate(t()) :: Tyyppi.Valuable.either()
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