exchema v0.4.0 Exchema.Types.OneOf

Represents one of the given types. Also known as a sum type.

For example:

iex> alias Exchema.Types, as: T
iex> t = {T.OneOf, [T.String, T.Integer]}
iex> Exchema.is?("string", t)
true

iex> Exchema.is?(100, t)
true

iex> Exchema.is?(:atom, t)
false

In case it fails, it will just return a invalid_type error.

If all the types are Structs, use Exchema.Types.OneStructOf