[Question] Tuple validation with enum in the first
eternaltyro opened this issue · 2 comments
eternaltyro commented
In the following schema,
{ "type": "array",
"items": [
{ "type": "number" },
{ "type": "string" },
{ "type": "string",
"enum": ["Street", "Avenue", "Boulevard"] },
{ "type": "string" } ] }
I'm trying to validate this: [1600, "Pennsylvania", "Avenue", "NW"]
Now, the documentation explains that it's okay to leave out items. What happens if I leave out the third item "Avenue". It would not validate the JSON because "NW" is not enumerated in the schema? This would especially get more interesting if the first item is enum . Like so:
{ "type":"array",
"items": [
{ "type": "string",
"enum": [ "Alice", "Bob", "Eve", "Mallory" ] },
{ "type": "string"} ]
}
Is there a way I can work around this problem?
eternaltyro commented
One obvious fix would be to always use the enum in the end. But if there are multiple enums, then it gets complicated.
mdboom commented
Indeed you are correct. You may want to ask your question on the JSON schema Google Group. These issues are strictly for the "Understanding JSON schema" book.