kata_form
Types
pub type FormError {
ParseError(message: String)
SchemaError(errors: List(error.Error))
}
Constructors
-
ParseError(message: String)Failed to parse URL-encoded form body
-
SchemaError(errors: List(error.Error))Schema validation failed
Values
pub fn decode(
schema: schema.Schema(a),
body: String,
) -> Result(a, FormError)
Decode a URL-encoded form body using a schema.
Use kata/coerce schemas for non-string fields.
pub fn decode_pairs(
schema: schema.Schema(a),
pairs: List(#(String, String)),
) -> Result(a, FormError)
Decode from pre-parsed key-value pairs (e.g. from wisp’s FormData.values).
pub fn format() -> format.Format(String)
Form format for use with kata/format.decode and kata/format.encode.
pub fn parse(body: String) -> Result(value.Value, String)
Parse a URL-encoded form body into a kata Value. Returns VObject with all values as VString.
pub fn serialize(v: value.Value) -> Result(String, String)
Serialize a Value to a URL-encoded form string. Only VObject with string-representable values is supported.