fix(core): Fix validation errors for nested props of same name#2531
Open
lucas-koehler wants to merge 2 commits intomasterfrom
Open
fix(core): Fix validation errors for nested props of same name#2531lucas-koehler wants to merge 2 commits intomasterfrom
lucas-koehler wants to merge 2 commits intomasterfrom
Conversation
- Remove obsolete safeguard against adding a property name a second time to a validation error's control path. - Add comment in errors.ts to clarify behavior - Add unit tests for getControlPath and errorAt - Add example for nested required property of same name fixes #2521
✅ Deploy Preview for jsonforms-examples ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
sdirix
requested changes
Mar 5, 2026
|
|
||
| const invalidProperty = getInvalidProperty(error); | ||
| if (invalidProperty !== undefined && !controlPath.endsWith(invalidProperty)) { | ||
| if (invalidProperty !== undefined) { |
Member
There was a problem hiding this comment.
Do you know why we originally added the endsWith check? There must have been a reason
Contributor
Author
There was a problem hiding this comment.
I'm not completely sure. Three reasons come to mind:
- AJV calculated error paths differently in the past
- This was a precaution that was never actually necessary
- We handled more cases in
getInvalidPropertyexplicitly in the past. However, the current three cases all need theinvalidPropertyattached anyway because they point to the parent object. See code snipped below
const getInvalidProperty = (error: ErrorObject): string | undefined => {
switch (error.keyword) {
case 'required':
case 'dependencies':
return error.params.missingProperty;
case 'additionalProperties':
return error.params.additionalProperty;
default:
return undefined;
}
};
Contributor
Author
|
@sdirix Thanks for the review 😊 I addressed the comments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #2521