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

FIO-9176: fix component path in error info #170

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/process/validation/__tests__/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ describe('interpolateErrors', () => {
processor: ProcessorType.Validate,
rules,
});
if(scope.errors[0]){
expect(scope.errors[0]?.context?.path).to.equal(path);
}
result.set(path, interpolateErrors(scope.errors));
});
expect(result.get('dataGrid[0].requiredField')).to.have.length(1);
Expand Down
4 changes: 3 additions & 1 deletion src/process/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ function handleError(error: FieldError | null, context: ValidationContext) {
const absolutePath = getComponentAbsolutePath(component);
if (error) {
const cleanedError = cleanupValidationError(error);
cleanedError.context.path = absolutePath;
if(component.parent){
cleanedError.context.path = absolutePath;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the behavior when the component is not in a parent? Is there a test for that case?

if (!find(scope.errors, { errorKeyOrMessage: cleanedError.errorKeyOrMessage, context: {
path: absolutePath
}})) {
Expand Down
Loading