Skip to content

Unify minimum/maximum error handlers with draft-04 compatibility#163

Merged
jdesrosiers merged 4 commits intohyperjump-io:mainfrom
Padmashree06:exclusive-min-max
Feb 24, 2026
Merged

Unify minimum/maximum error handlers with draft-04 compatibility#163
jdesrosiers merged 4 commits intohyperjump-io:mainfrom
Padmashree06:exclusive-min-max

Conversation

@Padmashree06
Copy link
Contributor

Description

This PR introduces unified error handlers for:

  • minimum, exclusiveMinimum and draft-04 minimum
  • maximum, exclusiveMaximum and draft-04 maximum

The handlers now select and report only the most restrictive constraint, producing a single validation error instead of multiple overlapping messages.

Additional Updates

  • Added normalization for the combined handlers
  • Included test cases.
  • Existing individual handlers are commented out in index.js to avoid overlap and can be removed if preferred.

Tests

All tests pass locally.

Fixes

Issue: #135

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.

The new error handlers look like the right idea, but there's a lot of cleanup that needs to be done everywhere else.

  • You need to rebase your branch and resolve conflicts
  • The old handlers need to be removed
  • There's no need for new normalization handlers
  • There should be no changes to hyperjump-json-schema.test.js

@Padmashree06
Copy link
Contributor Author

Thank you for the feedback.
I will do the necessary changes.

Regarding the changes to hyperjump-json-schema.test.js, I made those adjustments because I was running into some reference errors during testing. I’m sorry if modifying that file wasn’t the right approach. I’ll revert those changes and look into fixing the underlying issue properly instead.

@Padmashree06
Copy link
Contributor Author

I have removed the individual handlers and their corresponding normalization handlers, reverted the changes made in hyperjump-json-schema.test.js, and rebased to resolve the conflicts.

Please review

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 still haven't removed the maximum and minimum handlers. And you're still using a combined normalization handler. Normalization handlers are never combined, only error handlers. That's why they are defined separately.

@Padmashree06
Copy link
Contributor Author

Thank you for the feedback.
I have made the changes, please check.

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.

The new tests look great, but the one you changed isn't correct. Everything else looks good. I also asked for a few code style updates to better match the rest of the code base.

Comment on lines 10 to 14
const combinedMaximumErrorHandler = async (
normalizedErrors,
instance,
localization
) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please collapse this to one line.

/** @type (pointer: string) => string */
const pointerPop = (pointer) => pointer.replace(/\/[^/]+$/, "");

export default combinedMaximumErrorHandler;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to call this "combined". It can just be "maximumErrorHandler". (Same for the minimum handler.)

/** @type (exclusiveMaximum: number) => string */
getExclusiveMaximumErrorMessage(exclusiveMaximum) {
return this.#formatMessage("exclusiveMaximum-message", { exclusiveMaximum });
return this.#formatMessage("exclusiveMaximum-message", { exclusiveMaximum, maximum: exclusiveMaximum });
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change doesn't appear to be necessary. (Same for minimum.)

"schemaLocations": [
"#/maximum",
"#/exclusiveMaximum"
"#/maximum"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't right. In this case, both keywords need to be in schemaLocations because exclusiveMaximum alters maximum. After draft-04, it can be just the one that's most specific.

@Padmashree06
Copy link
Contributor Author

Thank you for the review.

  • I have renamed the combinedMaximum file to maximum.
  • I have modified the logic of maximum for draft04 to point to both maximum and exclusiveMaximum locations.
  • I have modified the test cases for draft04 to point to both maximum and exclusiveMaximum locations.
  • Same applies to minimum.
  • I have also made the necessary formatting changes.

Please let me know if there are any other changes to be made!

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.

@jdesrosiers jdesrosiers merged commit b37548d into hyperjump-io:main Feb 24, 2026
1 check passed
@Padmashree06
Copy link
Contributor Author

Thank you for merging!

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