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 all commits
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 @@ -89,6 +89,9 @@ describe('interpolateErrors', function () {
processor: ProcessorType.Validate,
rules,
});
if (scope.errors[0]) {
expect(scope.errors[0]?.context?.path).to.equal(path);
}
result.set(path, interpolateErrors(scope.errors));
},
);
Expand Down
3 changes: 3 additions & 0 deletions src/process/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ function handleError(error: FieldError | null, context: ValidationContext) {
const absolutePath = getComponentAbsolutePath(component);
if (error) {
const cleanedError = cleanupValidationError(error);
if (component.parent) {
cleanedError.context.path = absolutePath;
}
cleanedError.context.path = absolutePath;
Comment on lines +176 to 179
Copy link
Contributor

Choose a reason for hiding this comment

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

This change doesn't make sense to me. It seems to me that the path field will always be absolute path. What am I missing?

if (
!find(scope.errors, {
Expand Down
Loading