-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Hi, I'm struggling to work out why I'm getting inconsistent validation in a particular circumstance. In my schema I have an array of objects and a single text field. When one object in the array is missing the required "row" field and everything else is valid, I get the expected validation error:
data.project.NMAresults.1.row is required
However, when the "type" field is also missing, the only validation error is reporting "type" being missing.
data.project.type is required
I would expect both errors to appear in this second case. I have also checked my example using https://www.jsonschemavalidator.net and that gives the expected 2 errors.
I am using {jsonvalidate} 1.5.0 and R 4.4.2. the command I am using to get the validation messages is:
jsonvalidate::json_validate(json, schema, verbose = TRUE)
Is this something that I am doing wrong or misunderstanding?
Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"project": {
"type": "object",
"properties": {
"NMAresults": {
"type": "array",
"items": {
"type": "object",
"properties": {
"row": { "type": "string" }
},
"required": [
"row"
]
}
},
"type": {
"type": "string"
}
},
"required": [
"NMAresults",
"type",
]
}
},
"required": [ "project" ]
}
JSON Missing "row"
{
"project": {
"NMAresults": [
{
"row": "sleep:salad"
},
{
},
{
"row": "salad:exercise"
}
],
"type": "binary"
}
}
JSON Missing "row" and "type"
{
"project": {
"NMAresults": [
{
"row": "sleep:salad"
},
{
},
{
"row": "salad:exercise"
}
]
}
}