Hi I have a simple JSON array where the first item is always a string and 2..N items could be boolean or integer. eg.
[ "string", 1, 1, true, 1] // valid
[ "string", 1,1,"string" ] // invalid
[ "string", 1,1,1,1,1,1] // valid
I have tried to come up with a json schema to validate this but unfortunately says all the above are valid. Not sure if its possible to validate this in json shema ie a head and a tail? This list (array) can have any number of items. my attempt:
{
"type" : "array",
"items" : [
{ "$ref": "#/definitions/head" },
{ "$ref": "#/definitions/tail" }
],
"definitions": {
"head" : {
"type": "string"
},
"tail": { "anyOf" : [
{ "type" : "number" },
{ "type" : "boolean" }
]}
}
}
question from:https://stackoverflow.com/questions/65931437/json-schema-validate-head-and-tail-of-and-array