Skip to content

"prefixItems" in draft v7 #535

Answered by gregsdennis
hudeany asked this question in Q&A
Discussion options

You must be logged in to vote

prefixItems was added in 2020-12 when we split the schema-form items and array-form` items.

In previous versions, you can have the schema form

{
  "items": { "type": "object" }
}

which requires that every item in the array is an object.

You can also have the array form

{
  "items": [
    { "type": "object" }
  ]
}

which only requires that the first item is an object, and you can add more subschemas to validate more items in sequence.

additionalItems validates any items not validated by items. This means that for the schema-form items, additionalItems does nothing because there aren't any more items to validate.

For 2020-12, we split the array form of items off to prefixItems and got rid of

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by hudeany
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants