Skip to content

Conversation

@Adityakumar37
Copy link
Contributor

Hi @jdesrosiers

I made the required updates for draft-06/07 contains support:

Registered only the draft-06 keyword URI:
https://json-schema.org/keyword/draft-06/contains
(since draft-06 and draft-07 share the same keyword URI)

Added a draft-specific normalization handler at:
src/normalization-handlers/draft-06/contains.js
which implements the simpler draft-06 semantics (at least one matching item, no minContains/maxContains).

Updated the shared error handler (src/error-handlers/contains.js) to treat
draft-06/contains as a special case:

  • skips minContains/maxContains processing
  • always reports the default range { minContains: 1 }

All tests are passing locally, and lint/type-check are clean.

Please let me know if anything else should be adjusted.

Copy link
Collaborator

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the best we can do, then it doesn't make sense to use a shared handler. None of the meaningful code is shared, only the boilerplate.

However, I think it can be done in a way that makes sense for it to be shared. In draft-06, there is no minContains/maxContains keywords, so we can be confident that they will never be there. That means it doesn't hurt to check for them. If we just let them be checked regardless of which version of the keyword it is, I'm pretty sure things will just work. That was the entire handler can be the same and the only change needed is the loop to check for both keywor URIs.

@Adityakumar37
Copy link
Contributor Author

Thanks for the guidance!

  1. Removed the draft-06 specific normalization handler
  2. Reused the shared contains normalization handler for both URIs
  3. Kept only the loop that checks both keyword URIs

Copy link
Collaborator

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't reuse the normalization handler. They produce different values. The draft-06 version only has a string (the schema location). The current version is an object containing the schema location and the min/max constraints.

I noticed that you never enabled the draft-06 and draft-07 tests in the test runner. When you do that, you should see test failures from this bug.

@Adityakumar37
Copy link
Contributor Author

Thanks understood.

@Adityakumar37
Copy link
Contributor Author

Adityakumar37 commented Jan 30, 2026

Hi @jdesrosiers

when I enable the draft-06/07 tests I get this failure:

  • Expected: one contains-message error at the array root (#)
  • Received: multiple item-level type errors (Expected a number) for every element

So it seems my handler is returning per-item outputs instead of the boolean summary that the current contains error handler expects.

Could you confirm what the correct normalized output should be for draft-06 contains?

Should the draft-06 normalization handler:

  • behave exactly like the existing contains handler and return true/false, or
  • return item outputs and rely on different error handling?

Once I know the expected structure, I can fix it properly.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants