Validate extracted data against a schema definition (list format).
dot-validate_extracted_data.Rd
Checks if the structure, types, and required fields of the extracted data conform to the rules defined in the schema list (parsed from YAML).
Value
A list of validation error messages. An empty list indicates successful validation. Each error message includes the path to the problematic node.
Examples
if (FALSE) { # \dontrun{
# Assume schema_list is loaded from YAML using get_schema()
# Assume llm_output is the result from chat$extract_data(..., type = ellmer_schema)
schema_definition <- get_schema(".") # Or path to your schema YAML
# llm_output <- chat$extract_data(...) # Run your extraction
validation_errors <- validate_extracted_data(llm_output, schema_definition)
if (length(validation_errors) == 0) {
print("Validation successful!")
} else {
print("Validation failed with the following errors:")
purrr::walk(validation_errors, print) # Requires purrr package
# Or use base R:
# invisible(lapply(validation_errors, print))
}
} # }