Skip to content

Trimming alternatives for anyOf/oneOf based on type#170

Merged
jdesrosiers merged 5 commits intohyperjump-io:mainfrom
srivastava-diya:main
Feb 25, 2026
Merged

Trimming alternatives for anyOf/oneOf based on type#170
jdesrosiers merged 5 commits intohyperjump-io:mainfrom
srivastava-diya:main

Conversation

@srivastava-diya
Copy link
Contributor

Description

This PR improves the error reporting for anyOf and oneOf keywords by filtering out irrelevant schema alternatives based on the instance's type. This results in significantly cleaner error messages.

Fixes : #165

Changes

  1. The error handlers now check the type keyword of each alternative. If an alternative expects a type different from the instance it is excluded from the error report.

  2. If filtering results in only one alternative, then anyOf / oneOf wrapper error is removed entirely.

  3. If no alternatives match the instance type (or if types aren't specified), the original behavior is preserved all alternatives are reported.

@srivastava-diya
Copy link
Contributor Author

Hey @jdesrosiers , I've made some changes please have a look whenever you're free and tell me if I'm proceeding in the right direction.

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.

Looks good. The type check ended up being simpler that I expected which is great! I left a couple notes for some things that can be cleaned up a little.

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.

Looks great!

@jdesrosiers jdesrosiers merged commit 13babea into hyperjump-io:main Feb 25, 2026
1 check passed
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.

Discriminate between instance alternatives based on type

2 participants