Want.Boolean (want v1.14.0)

Performs type conversions to boolean values.

Link to this section Summary

Functions

Cast a value to a boolean.

Callback implementation for Want.Type.cast/2.

Link to this section Types

Specs

result() :: {:ok, boolean()} | {:error, binary()}

Link to this section Functions

Specs

cast(value :: any()) :: result()

Cast a value to a boolean.

Examples

iex> Want.Boolean.cast("true")

iex> Want.Boolean.cast("false")

iex> Want.Boolean.cast("TRUE")

iex> Want.Boolean.cast(1.0)

iex> Want.Boolean.cast(0)

iex> Want.Boolean.cast({:a, :b}) {:error, "Failed to convert value {:a, :b} to boolean."}

Link to this function

cast(value, opts)

Specs

cast(value :: any(), opts :: Keyword.t()) :: result()

Callback implementation for Want.Type.cast/2.