I am testing a schema (draft 2020-12) and data with the JSON Schema validator and I am wondering why the data is valid.
The test succeeds because the “contains” property is satisfied.
But when I am trying to invalidate the data with the first item of the first nested arrays, the test still succeeds because the item is not counted. Shouldn’t it be counted?
It is counted when both string have 5 chars and then the test fails, but not if only one string has 5 chars as below.
Below the schema and the data that passes the test and fails when all strings have 5 characters. Shouldn’t it fail now as 3 strings have 5 characters?
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"array": {
"type": "array",
"items": {
"items": {
"items": {
"properties": {
"c": {
"properties": {
"d": {
"maxLength": 6,
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"type": "array"
},
"type": "array"
},
"maxContains": 2,
"contains": {
"items": {
"items": {
"properties": {
"c": {
"properties": {
"d": {
"minLength": 5,
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"type": "array"
},
"type": "array"
}
}
},
"type": "object"
}
[
[
[
{
"c": {
"d": "abcd"
}
}
],
[
{
"c": {
"d": "abcde"
}
}
]
],
[
[
{
"c": {
"d": "abcde"
}
}
]
],
[
[
{
"c": {
"d": "abcde"
}
}
]
]
]