Want.Enum (want v1.10.0)
Provides type conversions to enumerations.
Link to this section 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.
Link to this section Types
Link to this type
result()
Specs
Link to this section Functions
Link to this function
cast(value, opts)
Specs
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])
iex> Want.Enum.cast("hello", valid: ["hello", :world])
Link to this function