Closed
Description
Environment
- Nuget Package: . JsonSchema.Net
- Nuget Version: 2.0.3
- OS: Linux & Windows
- .Net Target: 6
Describe the bug
First and before : Kudos for the awesome job 😍
Potentially related to #216
When validating a faulty schema with additionalProperties set to false, validation yields extraneous error messages ("All values fail against the false schema") those extraenous messages are not present when additionalProperties is set to true
To Reproduce
Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"additionalProperties": false,
"properties": {
"firstname": {"type": "string"},
"phone": {"type": "string"},
"email": {"$ref": "#/$defs/emailAddress"}
},
"required": ["firstname","phone","email"],
"$defs": {
"emailAddress": {
"type": "object",
"additionalProperties": false,
"properties": {
"email": {"type": "string"},
"isConfirmed": {"type": "boolean"}
},
"required": [ "email","isConfirmed"]
}
}
}
The following sample is missing the isConfirmed property
{
"firstname": "firstnameTest",
"phone": "123456",
"email": {
"email": "test@test.com"
}
}
This generates the following validation errors :
- Required properties [isConfirmed] were not present found at #/email
- All values fail against the false schema found at #/firstname
- All values fail against the false schema found at #/phone
- All values fail against the false schema found at #/email
Setting additionalProperties is set to true only one validation error is raised
- Required properties [isConfirmed] were not present found at #/email
Expected behavior
Behavior should be consistent independently from the additionalProperty property and should only report the first error