View Source Vx.Union (Vx v0.3.0)

The Union type combines multiple types into a single type, validating whether any of them is valid.

Summary

Functions

Builds a new Union type.

Types

Functions

@spec t(of) :: t(of) when of: [Vx.t(), ...]

Builds a new Union type.

Examples

iex> Vx.Union.t([Vx.Integer.t(), Vx.String.t()]) |> Vx.validate!(123)
:ok

iex> Vx.Union.t([Vx.Integer.t(), Vx.String.t()]) |> Vx.validate!(:foo)
** (Vx.Error) must be any of (integer | string)