Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid empty instancePath when propertyNames is violated #199

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jonasfj
Copy link

@jonasfj jonasfj commented Oct 30, 2024

Ultimate problem:

When validating a schema with the propertyNames applicator any errors produced had an empty instancePath.

How it was fixed:

This makes _validate take an Instance object instead of dynamic. And instead forces the callers to convert any values to Instance objects.

This is probably a good idea because:

  • Caller is the only one who can construct the instancePath.
  • It avoids a lot of unnecessary instance is! Instance checks 🚀

While fixing this I discovered that propertyNames errors were reported with an empty instancePath. Which could cause confusion for anyone trying to display the error.

Testing suggestions:

Test case included in PR.

Potential areas of regression:

Anyone depending on current behavior could be affected.
Most likely an empty instancePath is not what anyone is expecting.

This makes `_validate` take an `Instance` object instead of dynamic.
And instead forces the callers to convert any values to `Instance`
objects.

This is probably a good idea because:
 * Caller is the only one who can construct the `instancePath`.
 * It avoids a lot of unnecessary `instance is! Instance` checks.

Fixing this it was discovered that `propertyNames` errors were reported
with an empty `instancePath`. Which could cause confusion for anyone
trying to display the error.
Copy link

@michaelcarter-wf michaelcarter-wf left a comment

Choose a reason for hiding this comment

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

+1

@michaelcarter-wf
Copy link

QA +1

  • CI Passes
  • Test Case Added

@jonasfj Thanks for your contribution!

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

Successfully merging this pull request may close these issues.

3 participants