From 9d1e8b759fc5fea7de558f39759f46584245c8c6 Mon Sep 17 00:00:00 2001 From: "Maria.Golomb" Date: Tue, 15 Oct 2024 16:05:48 +0200 Subject: [PATCH] FIO-9176: fix component path in error info --- src/process/validation/__tests__/util.test.ts | 3 +++ src/process/validation/index.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/process/validation/__tests__/util.test.ts b/src/process/validation/__tests__/util.test.ts index 3d7aaf8a..8580980e 100644 --- a/src/process/validation/__tests__/util.test.ts +++ b/src/process/validation/__tests__/util.test.ts @@ -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); diff --git a/src/process/validation/index.ts b/src/process/validation/index.ts index 7469479b..41771cd6 100644 --- a/src/process/validation/index.ts +++ b/src/process/validation/index.ts @@ -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 }})) {