Comments (3)
Hi, @OussemaHammami.
Thank you for raising this to me and sorry for the inconvenience. I will check this as soon as possible
from json-schema-validator.
Hi, @OussemaHammami.
I reviewed the schema you shared and it looks like the behavior of the library is correct.
In the allOf
block you have an array of schemas with if-then
applicators. If the object passes if
applicator then
applicator is invoked. The if
applicator looks like this:
{
"if": {
"properties": {
"type": {
"enum": ["enum1", "enum2"]
}
}
}
}
According to JSON schema specification (I am referring to the latest draft but it is also true for previous ones):
Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, the child instance for that name successfully validates against the corresponding schema.
This means if an object has field type
the schema for this property will be applied to the field's value. If the object does not have this field (which is the case here) the schema for type
property won't be applied. As a result, the object passes if
applicator, and then
applicator is applied.
I think you could modify the if
schema to check if the object contains type
field:
{
"if": {
"properties": {
"type": {
"enum": ["enum1", "enum2"]
}
},
"required": ["type"]
}
}
If you do this the then
applicator should not be invoked and you should have only one validation error.
If you have any questions don't hesitate to ask. Kindly, close the issue if the above solves the problem.
from json-schema-validator.
Closing this issue as the library behavior matches the JSON specification.
@OussemaHammami if you have any more question about the library don't hesitate to ask by creating a new issue
from json-schema-validator.
Related Issues (20)
- Bug: implementation doesnโt pass new dynamicRef test suites
- Bug: id with absolute uri-reference results in incorrect reference resolution
- Enhancement: JsonPointer performance improvements
- Enhancement: support draft 6
- Enhancement: implement output formats described in JSON schema draft 2020-12
- Register custom Keywords HOT 4
- Add benchmarks for schema loading and validation execution
- Add support for Draft 2020-12
- Migrate to Kotlin 1.9
- Update workflows
- Support vocabulary customization through custom meta schema
- Correct circled references detection logic
- Add format keyword support
- Enhancement: support for dev containers
- Bug: multipleOf round error HOT 4
- Validation issue HOT 3
- Enhancement: Support $defs subschemas in Json HOT 3
- Bug: uri-reference in root `$id` results in incorrect reference resolution HOT 6
- Enhancement: Optimize generated classes with character data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-schema-validator.