want v1.1.1 Want.String
Manages conversions to and from strings.
Link to this section Summary
Link to this section Types
Link to this section Functions
Casts a given value to a string.
Options
:max
- Maximum allowable string length.:min
- Minimum allowable string length.- ':decode' - Currently only supports :uri; runs URI.decode on the input value
:matches
- The resulting string must match the given regex.
Examples
iex> Want.String.cast(1)
iex> Want.String.cast({:a, :b}) {:error, "Failed to convert value {:a, :b} to string."}
iex> Want.String.cast(:hello, max: 3)
iex> Want.String.cast(:a, min: 3)
iex> Want.String.cast("hello%20world", decode: :uri)
iex> Want.String.cast(:a, matches: ~r/a/)
Callback implementation for Want.Type.cast/2
.