Tyyppi.Valuable behaviour (tyyppi v0.12.1) View Source

The behaviour all participants of the Tyyppi’s operations should have implemented.

It’s implemented by Tyyppi.Value and Tyyppi.Struct, making them available for deep nested validations, coercion and generation.

Link to this section Summary

Types

Type returned from coercions and validations, typical pair of ok/error tuples, involving the value() as a main type behind

Type of the generation function, basically returning a stream of generated values

Type of the value behind the implementation

Callbacks

The coercion function, receiving the value()

Flattens the struct using the options passed

The generation function, returning the generator for the whole

The validation function, receiving the value()

Link to this section Types

Specs

either() :: {:ok, value()} | {:error, any()}

Type returned from coercions and validations, typical pair of ok/error tuples, involving the value() as a main type behind

Specs

generation() :: StreamData.t(value())

Type of the generation function, basically returning a stream of generated values

Specs

value() :: any()

Type of the value behind the implementation

Link to this section Callbacks

Specs

coerce(value()) :: either()

The coercion function, receiving the value()

Link to this callback

flatten( value, keyword )

View Source

Specs

flatten(
  value(),
  keyword()
) :: value()

Flattens the struct using the options passed

Specs

generation(value()) :: generation()

The generation function, returning the generator for the whole

Specs

validate(value()) :: either()

The validation function, receiving the value()