Skip to main content

extract_and_coerce_custom_data

Function extract_and_coerce_custom_data 

Source
pub fn extract_and_coerce_custom_data(
    form_data: &HashMap<String, String>,
    schema: &Value,
) -> Value
Expand description

Extract custom_data fields from form body, coerce types per schema, return as Value.

HTML forms submit everything as strings. This function:

  • Looks for keys starting with custom_data[ and strips the prefix/suffix.
  • Coerces values based on the schema property type.
  • For booleans, iterates schema properties so that absent checkboxes map to false.
  • Omits empty optional string fields from the result.