json-schema
json-schema copied to clipboard
How can I get errors for all instanceLocation?
Let's consider the following schema
{
"$id": "https://example.com/user-data",
"$schema": "http://json-schema.org/draft-07/schema",
"type": "object",
"properties": {
"name": { "type": "string", "default": "Unknown" },
"email": {
"type": "string",
"format": "email",
},
"tags": {
"type": "array",
"minItems": 3,
"items": { "type": "string", "minLength": 2 }
},
"score": { "type": "integer", "minimum": 0 },
"date": { "type": "integer", "format": "unix-time" },
"nospace": {
"pattern": "^\\S*$",
"type": "string"
},
"extra": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"required": ["name", "email", "tags", "score", "extra"],
}
I am getting errors only for tags property for the following json
{
"name": "Unknown",
"email": "",
"tags": [],
"score": -50,
"extra": 123
}
Currently the library only supports short circuit evaluation, so it will stop evaluating after the first error.
However, I have the all-errors functionality implemented, so you can expect that to be released relatively soon.
(Related discussion: https://github.com/hyperjump-io/json-schema/discussions/32)
Okay then eagerly waiting 😊
This functionality was released with v1.9.0 on May 3. Sorry for forgetting to update this thread.