View Source
Vx.Nullable
(Vx v0.4.0)
The Nullable type modifies a type or value to allow nil
as a valid value.
Summary
Builds a new type that makes the passed type nullable.
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)