envie/decode
Types
Values
pub fn bool() -> Decoder(Bool)
Parse a boolean. Accepts (case-insensitive): true/yes/1/on → True; false/no/0/off → False.
pub fn float_range(
min min: Float,
max max: Float,
) -> Decoder(Float)
Parse a float that must be within [min, max].
pub fn int_list(
separator separator: String,
) -> Decoder(List(Int))
Split a string by a separator and parse each element as an integer.
pub fn int_range(min min: Int, max max: Int) -> Decoder(Int)
Parse an integer that must be within [min, max].
pub fn map(decoder: Decoder(a), f: fn(a) -> b) -> Decoder(b)
Transform the decoded value with a pure function.
pub fn non_empty_string() -> Decoder(String)
Require a non-empty (after trimming) string.
pub fn one_of(allowed: List(String)) -> Decoder(String)
Accept only values that appear in allowed (case-sensitive).
pub fn string_list(
separator separator: String,
) -> Decoder(List(String))
Split a string by a separator into a list of trimmed, non-empty strings.
pub fn string_prefix(prefix: String) -> Decoder(String)
Require that the string starts with a given prefix.
pub fn then(
decoder: Decoder(a),
f: fn(a) -> Result(b, String),
) -> Decoder(b)
Chain a decoder with a fallible transformation.
pub fn url() -> Decoder(uri.Uri)
Parse a valid URI. Note that this is very permissive (accepts “localhost”, etc.).
Use url_with_scheme or web_url for stricter validation.
pub fn url_with_scheme(schemes: List(String)) -> Decoder(uri.Uri)
Parse a valid URI that must have one of requested schemes (e.g., [“https”]).