View Source Vx.List (Vx v0.1.0)
The List type.
Summary
Types
@opaque t()
The list type.
Functions
@spec max_size(t(), non_neg_integer()) :: t()
@spec min_size(t(), non_neg_integer()) :: t()
@spec size(t(), non_neg_integer()) :: t()
@spec t() :: t()
Builds a new List type.
Examples
iex> Vx.List.t() |> Vx.validate!([1, 2, 3])
:ok
iex> Vx.List.t() |> Vx.validate!("foo")
** (Vx.Error) must be a list
Builds a new List type with the given inner type.
Examples
iex> Vx.List.t(Vx.Number.t()) |> Vx.validate!([1, 2, 3])
:ok
iex> Vx.List.t(Vx.String.t()) |> Vx.validate!("foo")
** (Vx.Error) must be a list
iex> Vx.List.t(Vx.String.t()) |> Vx.validate!(["foo", 2, "bar"])
** (Vx.Error) must be a list<string>
- element 1: must be a string