View Source Vx.Nullable (Vx v0.1.0)

The Nullable type modifies a type or value to allow nil as a valid value.

Summary

Functions

Builds a new type that makes the passed type nullable.

Types

Functions

@spec t(of) :: t(of) when of: any()

Builds a new type that makes the passed type nullable.

Examples

iex> Vx.Nullable.t(Vx.String.t()) |> Vx.validate!("foo")
:ok

iex> Vx.Nullable.t(Vx.String.t()) |> Vx.validate!(nil)
:ok

iex> Vx.Nullable.t(Vx.String.t()) |> Vx.validate!(123)
** (Vx.Error) must be (string | nil)