unevaluatedProperties now cascade infinitely down their leaf when strict validation mode is on
This commit is contained in:
27
src/tests.rs
27
src/tests.rs
@ -452,6 +452,33 @@ fn test_validate_unevaluated_properties() {
|
||||
|
||||
let valid_result = validate_json_schema("simple_unevaluated_test.request", jsonb(valid_instance));
|
||||
assert_success(&valid_result);
|
||||
|
||||
// Test 4: Test that unevaluatedProperties: true cascades down refs
|
||||
let cascading_instance = json!({
|
||||
"strict_branch": {
|
||||
"another_prop": "is_ok"
|
||||
},
|
||||
"non_strict_branch": {
|
||||
"extra_at_toplevel": "is_ok", // Extra property at this level
|
||||
"some_prop": {
|
||||
"deep_prop": "is_ok",
|
||||
"extra_in_ref": "is_also_ok" // Extra property in the $ref'd schema
|
||||
}
|
||||
}
|
||||
});
|
||||
let cascading_result = validate_json_schema("nested_unevaluated_test.request", jsonb(cascading_instance));
|
||||
assert_success(&cascading_result);
|
||||
|
||||
// Test 5: For good measure, test that the strict branch is still strict
|
||||
let strict_fail_instance = json!({
|
||||
"strict_branch": {
|
||||
"another_prop": "is_ok",
|
||||
"extra_in_strict": "is_not_ok"
|
||||
}
|
||||
});
|
||||
let strict_fail_result = validate_json_schema("nested_unevaluated_test.request", jsonb(strict_fail_instance));
|
||||
assert_error_count(&strict_fail_result, 1);
|
||||
assert_has_error(&strict_fail_result, "ADDITIONAL_PROPERTIES_NOT_ALLOWED", "/strict_branch/extra_in_strict");
|
||||
}
|
||||
|
||||
#[pg_test]
|
||||
|
||||
Reference in New Issue
Block a user