boon now included

This commit is contained in:
2025-09-30 01:10:58 -04:00
parent c9b1245a57
commit cc04f38c14
77 changed files with 12905 additions and 52 deletions

View File

@ -371,11 +371,10 @@ fn validate_json_schema(schema_id: &str, instance: JsonB) -> JsonB {
let mut error_list = Vec::new();
collect_errors(&validation_error, &mut error_list);
let errors = format_errors(error_list, &instance_value, schema_id);
let filtered_errors = filter_false_schema_errors(errors);
if filtered_errors.is_empty() {
if errors.is_empty() {
JsonB(json!({ "response": "success" }))
} else {
JsonB(json!({ "errors": filtered_errors }))
JsonB(json!({ "errors": errors }))
}
}
}
@ -391,19 +390,6 @@ fn collect_errors(error: &ValidationError, errors_list: &mut Vec<Error>) {
ErrorKind::Group | ErrorKind::AllOf | ErrorKind::AnyOf | ErrorKind::Not | ErrorKind::OneOf(_)
);
// Special handling for FalseSchema - if it has causes, use those instead
if matches!(&error.kind, ErrorKind::FalseSchema) {
if !error.causes.is_empty() {
// FalseSchema often wraps more specific errors in if/then conditionals
for cause in &error.causes {
collect_errors(cause, errors_list);
}
return;
}
// If FalseSchema has no causes, it's likely from unevaluatedProperties
// We'll handle it as a leaf error below
}
if error.causes.is_empty() && !is_structural {
let base_path = error.instance_location.to_string();
@ -892,32 +878,6 @@ fn handle_one_of_error(base_path: &str, matched: &Option<(usize, usize)>) -> Vec
}]
}
// Filter out FALSE_SCHEMA errors if there are other validation errors
fn filter_false_schema_errors(errors: Vec<Value>) -> Vec<Value> {
// Check if there are any non-FALSE_SCHEMA errors
let has_non_false_schema = errors.iter().any(|e| {
e.get("code")
.and_then(|c| c.as_str())
.map(|code| code != "FALSE_SCHEMA")
.unwrap_or(false)
});
if has_non_false_schema {
// Filter out FALSE_SCHEMA errors
errors.into_iter()
.filter(|e| {
e.get("code")
.and_then(|c| c.as_str())
.map(|code| code != "FALSE_SCHEMA")
.unwrap_or(true)
})
.collect()
} else {
// Keep all errors (they're all FALSE_SCHEMA)
errors
}
}
// Formats errors according to DropError structure
fn format_errors(errors: Vec<Error>, instance: &Value, schema_id: &str) -> Vec<Value> {
// Deduplicate by instance_path and format as DropError