You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful to have a tuple validation with optional items, it could act similarly to the object's keyword properties but with forced order.
So for example if the schema mandated first the number 1 followed by 2, it could match any combination of them (missing or present) except for a 2 followed by a 1; since even though they are valid items the schemas which validated them are not in order.
This could be implemented reusing the required keyword for arrays, which could contain an array of item indices. Additionally it could also be set to true specifying all items are required (acting like tuple validation) or false marking all items as optional. If not present it can be assumed to be true for backward compatibility reasons or following the behaviour in objects false.
List validation currently seems to act as a set validation, since order is not taken into account, but it gives flexibility in terms of the array length. Tuple validation however takes the order into consideration, but forces a fixed number of items to be present, with additionalItems just concatenating the set validation. Implementing it would allow for a more flexible but order persistent array validation, similar to actual lists.
It's inclusion would re-enable a similar behavior to the one present in Draft-03; allowing additional items to be present at specific positions instead of at the end without order. Additionally when setting all items to optional it would enable arrays to contain an arbitrary amount of items while still being order by a certain criteria.
It would be useful to have a tuple validation with optional items, it could act similarly to the object's keyword
properties
but with forced order.So for example if the schema mandated first the number 1 followed by 2, it could match any combination of them (missing or present) except for a 2 followed by a 1; since even though they are valid items the schemas which validated them are not in order.
This could be implemented reusing the
required
keyword for arrays, which could contain an array of item indices. Additionally it could also be set totrue
specifying all items are required (acting like tuple validation) orfalse
marking all items as optional. If not present it can be assumed to be true for backward compatibility reasons or following the behaviour in objectsfalse
.The exact behaviour might be better off following the result of json-schema-org/json-schema-spec#659.
The text was updated successfully, but these errors were encountered: