Status
Proposed, accepted, reconsidered, and ultimately revertedDeciders
@gregsdennis, @jdesrosiers, @handrews, @awwright, @karenetheridge, @relequestual (with input from non-core members)Date
November 14, 2023 (documented February 9, 2024)Context and Problem Statement
Thecontains keyword originally applied only to arrays. The question arose: Should contains also apply to objects?
This ADR documents a decision that was made, reconsidered, and ultimately reverted - an important example of how stability concerns influenced the specification development process.
Timeline
[2021-02] - The original proposal was forcontains to apply to objects as well as arrays since there was no functionality to do so. The discussion covered:
- Modifying
containsto work with objects - Introducing a new
objectContains(or similar) keyword set
contains won.
[2021-06] - A change was applied to allow contains for objects.
[2022-12] - With the team shifting focus to stability between spec releases, the question was raised again with the argument that allowing contains to apply to objects is a breaking change. It was conceded that the better approach would be to retain contains only for arrays and introduce a new keyword set to apply to objects.
[2023-11] - The change was applied (reverted to previous behavior).
Decision Drivers
- The original decision to allow
containsto apply to objects was driven by the fact that no such functionality existed - The decision to revert was driven by a desire to not break current usages of
contains - Stability guarantees became a higher priority than feature addition
Considered Options
- Modify
containsto apply to objects - Introduce new keyword set (e.g.,
objectContainsalong with associated min/max)
Decision Outcome
Ultimately,contains will continue to apply to only arrays.
New keywords will need to be introduced to apply to objects. (Such a proposal has not yet been made.)
Use Case Example
A user in Slack provided this real-world requirement: Requirement: An object may contain any number of properties, but one and only one of them must contain an object with atitle property.
Valid Instance
Invalid Instances
Analysis of Options
Option 1: Change contains to Work with Objects
If contains worked with objects, the schema would be:
- ✅ Provides functionality that previously did not exist
- ✅ Reuses existing keyword rather than adding new ones
- ❌ Breaking change: Can potentially break existing schemas
- ❌ Schemas using
containswithout atype: arrayspecifier would suddenly start applying to objects also - ❌ Violates stability guarantees
Option 2: Introduce New Keywords (Chosen)
Introduce new keywords:objectContains, objectMinContains, objectMaxContains
The schema would look like:
- ✅ Provides functionality that previously did not exist
- ✅ Doesn’t break anyone - maintains backward compatibility
- ✅ Aligns with stability-first development approach
- ⚠️ Requires introducing three new keywords
- ⚠️ More keywords to learn and document
Consequences
Positive Consequences
- ✅ Schemas which currently use
containswithout atype: arrayspecifier will not suddenly start applying to objects - ✅ Maintains backward compatibility
- ✅ Upholds stability guarantees established in the Stable Spec ADR
- ✅ Demonstrates commitment to not breaking existing schemas
Negative Consequences
- ❌ The functionality of
containsas applied to objects is still unsupported - ⚠️ Users who need this functionality must wait for new keywords to be proposed and accepted
- ⚠️ If new keywords are added, there will be some asymmetry between array and object approaches
Current Status
As of the v1/2026 release:- ✅
contains,minContains, andmaxContainswork only with arrays - ⏳ No
objectContainsequivalent has been proposed yet - 💡 Community members are encouraged to submit a proposal if they need this functionality
This ADR demonstrates the specification’s commitment to stability over feature addition, even when reverting previously accepted changes.