caffeine_lang/common/decoders

Values

pub fn accepted_types_decoder() -> decode.Decoder(
  accepted_types.AcceptedTypes,
)

Decoder for AcceptedTypes from a raw string representation. i.e. for “Dict(String, String)” will return a decoder for Ok(helpers.Dict(helpers.String, helpers.String))).

Note that the default for the error is decode.failure(Boolean, “AcceptedType”) which is a bit odd, but nonetheless should do the job for now.

pub fn decode_list_values_to_strings(
  inner_type: accepted_types.AcceptedTypes,
) -> decode.Decoder(List(String))

Decoder that decodes a list of dynamic values and returns a List(String).

pub fn decode_value_to_string(
  typ: accepted_types.AcceptedTypes,
) -> decode.Decoder(String)

Decoder that decodes a dynamic value based on an AcceptedTypes and returns its String representation.

pub fn named_reference_decoder(
  collection: List(a),
  name_extraction: fn(a) -> String,
) -> decode.Decoder(String)

Creates a decoder that validates a string is a valid reference to an item in a collection. Returns the string if it matches a name in the collection, otherwise fails decoding.

pub fn non_empty_string_decoder() -> decode.Decoder(String)

Decoder for non-empty strings. Fails if the string is empty.

Search Document