View Source Want.Enum (want v1.17.1)
Provides type conversions to enumerations.
Summary
Functions
Cast a given value to an enum value. The given options keyword list must include an array of valid enum values under the :valid key, otherwise the function will return an error tuple.
Types
Functions
Cast a given value to an enum value. The given options keyword list must include an array of valid enum values under the :valid key, otherwise the function will return an error tuple.
Options
:valid
- List of valid enum values. The input must loosely match one of these.
Examples
iex> Want.Enum.cast("hello", valid: [:hello, :world])
{:ok, :hello}
iex> Want.Enum.cast("hello", valid: ["hello", :world])
{:ok, "hello"}