Skip to content

Commit

Permalink
FIO-9176: fix component path in error info
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria.Golomb committed Oct 15, 2024
1 parent 1a100f3 commit 9d1e8b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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;
}
if (!find(scope.errors, { errorKeyOrMessage: cleanedError.errorKeyOrMessage, context: {
path: absolutePath
}})) {
Expand Down

0 comments on commit 9d1e8b7

Please sign in to comment.