Goal
Add support for advanced Draft 2020-12 unevaluated keywords:
unevaluatedProperties
unevaluatedItems
Plain-language explanation
additionalProperties: false only knows about properties declared in the same object schema.
With composition, such as allOf, properties can be declared across multiple schemas. unevaluatedProperties: false says: after all those schemas have had a chance to validate their known properties, reject any remaining unknown properties.
Example
Possible DSL:
all_of :person do
object do
string :name
end
object do
integer :age
end
unevaluated_properties false
end
Valid value:
{ "name": "Alice", "age": 30 }
Invalid value:
{ "name": "Alice", "age": 30, "unknown": true }
For arrays, unevaluatedItems is similar: after tuple/items/contains rules have handled known items, reject or validate remaining items.
Possible DSL:
array :values, unevaluated_items: false do
tuple do
string
integer
end
end
Acceptance criteria
- Works with composition or
$ref schemas.
- Behavior tests cover interaction with
allOf or $ref.
- Generated schemas validate against Draft 2020-12.
Goal
Add support for advanced Draft 2020-12 unevaluated keywords:
unevaluatedPropertiesunevaluatedItemsPlain-language explanation
additionalProperties: falseonly knows about properties declared in the same object schema.With composition, such as
allOf, properties can be declared across multiple schemas.unevaluatedProperties: falsesays: after all those schemas have had a chance to validate their known properties, reject any remaining unknown properties.Example
Possible DSL:
Valid value:
{ "name": "Alice", "age": 30 }Invalid value:
{ "name": "Alice", "age": 30, "unknown": true }For arrays,
unevaluatedItemsis similar: after tuple/items/contains rules have handled known items, reject or validate remaining items.Possible DSL:
Acceptance criteria
$refschemas.allOfor$ref.