There's not really a way to simulate minContains/maxContains in draft-07. Here's some examples of the closest you can get.
Like "minContains": 2, if you have a fixed number of elements. It's not pretty, but you can enumerate all the possible ways the two items can appear in the array.
{
"type": "array",
"maxItems": 4,
"minItems": 4,
"anyOf": [
{
"items": [
{ "$ref": "#/definitions/isCorrect-true" },
{ "$ref": "#/definitions/isCorrect-true" }
]
},
{
"items": [
{ "$ref": "#/definitions/isCorrect-true" },
true,
{ "$ref": "#/definitions/isCorrect-true" }
]
},
{
"items": [
{ "$ref": "#/definitions/isCorrect-true" },
true,
true,
{ "$ref": "#/definitions/isCorrect-true" }
]
},
{
"items": [
true,
{ "$ref": "#/definitions/isCorrect-true" },
{ "$ref": "#/definitions/isCorrect-true" }
]
},
{
"items": [
true,
{ "$ref": "#/definitions/isCorrect-true" },
true,
{ "$ref": "#/definitions/isCorrect-true" }
]
},
{
"items": [
true,
true,
{ "$ref": "#/definitions/isCorrect-true" },
{ "$ref": "#/definitions/isCorrect-true" }
]
}
],
"definitions": {
"isCorrect-true": {
"type": "object",
"properties": {
"isCorrect": { "const": true }
}
}
}
}
Like "minContains": 2, except all the true items need to be first in the array.
{
"type": "array",
"items": [
{ "$ref": "#/definitions/isCorrect-true" },
{ "$ref": "#/definitions/isCorrect-true" }
],
"definitions": {
"isCorrect-true": {
"type": "object",
"properties": {
"isCorrect": { "const": true }
}
}
}
}
Like "maxContains": 2, except all the true items need to be first in the array.
{
"type": "array",
"items": [
true,
true
],
"additionalItems": { "not": { "$ref": "#/definitions/isCorrect-true" } },
"definitions": {
"isCorrect-true": {
"type": "object",
"properties": {
"isCorrect": { "const": true }
}
}
}
}
Like "minContains": 2, "maxContains": 2, except all the true items need to be first in the array.
{
"type": "array",
"items": [
{ "$ref": "#/definitions/isCorrect-true" },
{ "$ref": "#/definitions/isCorrect-true" }
],
"additionalItems": { "not": { "$ref": "#/definitions/isCorrect-true" } },
"definitions": {
"isCorrect-true": {
"type": "object",
"properties": {
"isCorrect": { "const": true }
}
}
}
}