pub fn validate_document(
doc: &Document,
form: &FormDefinition,
) -> Result<(), Vec<DocumentValidationError>>Expand description
Validates a Document against its FormDefinition.
This function performs a comprehensive check, ensuring:
- The
Document’sform_idmatches theFormDefinition’s ID. - All
requiredfields as defined in theFormDefinitionare present and not null in theDocument. - Data types for each field in the
Documentmatch theFieldTypespecified in theFormDefinition. - Specific constraints (e.g.,
min/maxfor numbers,optionsfor selects, ISO 8601 for dates) are met.
§Arguments
doc- A reference to theDocumentto be validated.form- A reference to theFormDefinitionto validate against.
§Returns
A Result which is Ok(()) if the document is valid, or Err(Vec<DocumentValidationError>)
containing a list of all validation errors found.