View Source Vx.Struct (Vx v0.3.0)

The Struct type.

Summary

Types

t()

The struct type.

Functions

t()

Builds a new Struct type matching any type of struct.

Builds a new Struct type matching a specific type of struct.

Types

@opaque t()

The struct type.

Functions

@spec t() :: t()

Builds a new Struct type matching any type of struct.

Examples

iex> Vx.Struct.t() |> Vx.validate!(%Address{})
:ok

iex> Vx.Struct.t() |> Vx.validate!(%{})
** (Vx.Error) must be a struct

Builds a new Struct type matching a specific type of struct.

Examples

iex> Vx.Struct.t(Address) |> Vx.validate!(%Address{})
:ok

iex> Vx.Struct.t(Address) |> Vx.validate!(%{})
** (Vx.Error) must be a struct of type Address

iex> Vx.Struct.t(Address) |> Vx.validate!(%Country{})
** (Vx.Error) must be a struct of type Address