Skip to content

Add unevaluated keywords #38

Description

@crmne

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions