Want.String (want v1.13.1)
Manages conversions to and from strings.
Link to this section Summary
Link to this section Types
Link to this type
result()
Specs
Link to this section Functions
Link to this function
cast(value)
Specs
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/)
Link to this function
cast(value, opts)
Specs
Callback implementation for Want.Type.cast/2
.