View Source Vx.List (Vx v0.1.0)

The List type.

Summary

Types

t()

The list type.

Types

@opaque t()

The list type.

Functions

Link to this function

max_size(type \\ t(), size)

View Source
@spec max_size(t(), non_neg_integer()) :: t()
Link to this function

min_size(type \\ t(), size)

View Source
@spec min_size(t(), non_neg_integer()) :: t()
@spec non_empty(t()) :: t()
Link to this function

shape(type \\ t(), shape)

View Source
@spec shape(t(), [Vx.t()]) :: 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
@spec t(Vx.t()) :: t()

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