fix(core): Fix validation errors for nested props of same name#2531
Open
lucas-koehler wants to merge 1 commit intomasterfrom
Open
fix(core): Fix validation errors for nested props of same name#2531lucas-koehler wants to merge 1 commit intomasterfrom
lucas-koehler wants to merge 1 commit 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
|
|
||
| /** | ||
| * Checks for an additionally specified property that the error relates to. | ||
| * This may be added to an error's instancePath to show it add the violating property's control. |
Member
There was a problem hiding this comment.
Typo: "to show it add the violating" should be "to show it at the violating".
|
|
||
| // remove '.' chars at the beginning of paths | ||
| controlPath = controlPath.replace(/^./, ''); | ||
| controlPath = controlPath.replace(/^\./, ''); |
| t.is(controlPath, 'parent.child'); | ||
| }); | ||
|
|
||
| test('getControlPath - prevents duplicate property when path already ends with property', (t) => { |
Member
There was a problem hiding this comment.
This test name is misleading. It says "prevents duplicate" but this is not what we want?
| import * as string from './examples/string'; | ||
| import * as prependAppendSlots from './examples/prepend-append-slots'; | ||
| import * as validationNestedSameNameValidation from './examples/validation-nested-same-name'; | ||
| export * from './register'; |
Member
There was a problem hiding this comment.
nit: validationNestedSameNameValidation has redundant "Validation" in the name. validationNestedSameName would be enough.
|
|
||
| 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
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