Skip to content

feat: Support unevaluatedItems in Draft 2019-09 - #983

Open
Roman3349 wants to merge 1 commit into
jsonrainbow:mainfrom
Roman3349:feat/unevaluated-items
Open

Roman3349 wants to merge 1 commit into
jsonrainbow:mainfrom
Roman3349:feat/unevaluated-items

Conversation

@Roman3349

@Roman3349 Roman3349 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Draft 2019-09 ignored the unevaluatedItems keyword, so arrays with items that no other keyword evaluated passed validation.

This adds UnevaluatedItemsConstraint, built the same way as UnevaluatedPropertiesConstraint. In Draft 2019-09 the evaluated items are always at the start of the array, so the constraint only counts how many leading items are evaluated by:

  • items (a schema evaluates every item; an array of schemas evaluates the first N items),
  • additionalItems next to an array-form items (every item),
  • a nested unevaluatedItems: true (every item),
  • the valid branches of $ref, allOf, anyOf, oneOf and if/then/else (not is ignored).

The remaining items are checked against the unevaluatedItems schema. When unevaluatedItems is false, each one is reported as a new ConstraintError::UNEVALUATED_ITEMS at its own index.

Related Issue

None.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Other (please describe):

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective or that my feature works
  • All new and existing tests pass
  • I have updated the documentation accordingly
  • My changes generate no new warnings

Additional Notes

The unevaluatedItems keyword was ignored, so arrays with items that no
other keyword evaluated passed validation.

In Draft 2019-09 the evaluated items always form a prefix of the array,
so the constraint derives how many leading items are evaluated by items,
additionalItems, nested unevaluatedItems and the valid branches of $ref,
allOf, anyOf, oneOf and if/then/else. The remaining items are validated
against the unevaluatedItems schema or reported as unevaluated.

The JSON Schema Test Suite cases for unevaluatedItems are no longer
skipped, except those relying on $recursiveRef. The ref.json case
"$ref with $recursiveAnchor: extra items allowed for inner arrays" is
skipped now, as $ref "#" resolves against the root schema instead of the
embedded $id resource.

Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
@Roman3349
Roman3349 force-pushed the feat/unevaluated-items branch from 3a57f40 to 71c0244 Compare October 18, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants