Tyyppi.Example.Nested (tyyppi v0.7.2) View Source

Example of the nested structure defined with Tyyppi.Struct.defstruct/1

Link to this section Summary

Types

t()

The type describing this struct. This type will be used to validate upserts when called via Access and/or Tyyppi.Example.Nested.put/3, Tyyppi.Example.Nested.update/4.

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

dt() :: binary()

Specs

t() :: %Tyyppi.Example.Nested{
  date_time: Tyyppi.Value.t(DateTime.t()),
  struct: Tyyppi.Example.Value.t()
}

The type describing this struct. This type will be used to validate upserts when called via Access and/or Tyyppi.Example.Nested.put/3, Tyyppi.Example.Nested.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

update(target :: t(), values :: keyword()) :: {:ok, t()} | {:error, keyword()}

Updates the struct

Specs

validate(t()) :: {:ok, t()} | {:error, term()}

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