unevaluatedItems and unevaluatedProperties keywords allow schema authors to apply subschemas to array items or object properties that have not been successfully evaluated against any subschema from adjacent keywords.
Overview
These keywords enable schema authors to:- Control validation of array items or object properties not covered by other keywords
- Implement “closed” schemas that disallow unexpected data
- Combine multiple schemas while maintaining control over what is allowed
Only successful evaluations are considered. Instance items or properties may have been unsuccessfully evaluated against one or more subschemas (such as a failed
anyOf branch) without being considered “evaluated.”What Does “Evaluated” Mean?
An item in an array or property in an object is “successfully evaluated” if it is logically considered valid in terms of the expected representation. Example: If a subschema represents a car requiring between 2-4 wheels, and the value of “wheels” is 6, the instance object is not “evaluated” to be a car, and thus the “wheels” property is considered “unevaluated.”Adjacent Keywords
Adjacent keywords are keywords within the same schema object. The behavior of unevaluated keywords depends on:- Adjacent keywords in the same schema object
- Keywords in successfully validated subschemas that apply to the same instance location
- Lexical subschemas
- Reference targets (like
$ref) - All in-place applicators (
allOf,anyOf,oneOf, etc.)
unevaluatedItems
The value ofunevaluatedItems must be a valid JSON Schema. This keyword applies to array instances by applying its subschema to the array’s elements.
How It Works
The keyword applies its subschema to any array elements which have not been deemed “evaluated.” Validation passes if the keyword’s subschema validates against all applicable array elements.Interacting Keywords
The behavior depends on:prefixItemsitemscontainsunevaluatedItemsitself- All in-place applicators
Example: Basic Usage
- ✅ Validates:
["foo", 42] - ❌ Rejects:
["foo", 42, "extra"](third item is unevaluated)
Example: With Composition
allOf successfully evaluate, items at indices 0 and 1 are considered evaluated. Any additional items would be unevaluated.
Example: Extending Schemas
- First two validated by the referenced schema
- Third validated by the local
prefixItems - No additional items allowed
Annotation Result
If theunevaluatedItems subschema is applied to any positions within the instance array, it produces an annotation result of boolean true, analogous to the behavior of items.
Omitting this keyword has the same assertion behavior as an empty schema, meaning unevaluated items are allowed by default.
unevaluatedProperties
The value ofunevaluatedProperties must be a valid JSON Schema. This keyword applies to object instances by applying its subschema to the object’s property values.
How It Works
The keyword applies its subschema to any property values which have not been deemed “evaluated.” Validation passes if the keyword’s subschema validates against all applicable property values.Interacting Keywords
The behavior depends on:propertiespatternPropertiesadditionalPropertiesunevaluatedPropertiesitself- All in-place applicators
Example: Basic Usage
- ✅ Validates:
{"name": "Alice"} - ❌ Rejects:
{"name": "Alice", "age": 30}(“age” is unevaluated)
Example: With Composition
allOf subschemas, so they are allowed. Any other properties would be rejected.
Example: Extending Base Schemas
- “name” and “age” come from the referenced schema
- “employeeId” is added locally
- No other properties are allowed
Example: Complex Composition
oneOf branch validates:
- User type: allows “type” and “username”
- Admin type: allows “type” and “adminLevel”
- No other properties allowed in either case
Annotation Result
The annotation result of this keyword is the set of instance property names validated by this keyword’s subschema.Omitting this keyword has the same assertion behavior as an empty schema, meaning unevaluated properties are allowed by default.
Important Considerations
Evaluation Path Matters
Dynamic Scope
Unevaluated keywords consider the dynamic scope of evaluation, not just the lexical structure. This means:- They look at schemas encountered during evaluation
- They follow
$refand$dynamicRefreferences - They respect the evaluation path, not just the schema structure
Short-Circuit Evaluation
When
unevaluatedItems or unevaluatedProperties appears in any subschema in the dynamic scope, certain keywords (like contains) must evaluate all applicable items to ensure proper tracking of evaluated locations.