want v1.1.1 Want.Integer

Manages conversions to and from integers.

Link to this section Summary

Functions

Cast a value to an integer.

Callback implementation for Want.Type.cast/2.

Link to this section Types

Link to this type

result()

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

Link to this section Functions

Cast a value to an integer.

Options

  • :max - Maximum allowable integer value.
  • :min - Minimum allowable integer value.

Examples

iex> Want.Integer.cast("1")

iex> Want.Integer.cast(1.0)

iex> Want.Integer.cast(:'1')

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

iex> Want.Integer.cast("10", max: 3)

iex> Want.Integer.cast(1.0, min: 3)

Link to this function

cast(value, opts)

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

Callback implementation for Want.Type.cast/2.