Skip to content

Commit

Permalink
fix: create the base paths outside the map iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Jan 5, 2025
1 parent 7fd36c1 commit 9ca5949
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/standardSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ function createStandardIssues(
error: ValidationError,
parentPath?: string,
): StandardIssue[] {
const path = parentPath ? `${parentPath}.${error.path}` : error.path;

return error.errors.map(
(err) =>
({
message: err,
path: createStandardPath(
parentPath ? `${parentPath}.${error.path}` : error.path,
),
path: createStandardPath(path),
} satisfies StandardIssue),
);
}
Expand All @@ -170,10 +170,7 @@ function issuesFromValidationError(
return createStandardIssues(error, parentPath);
}

return error.inner.flatMap((err) =>
issuesFromValidationError(
err,
parentPath ? `${parentPath}.${error.path}` : error.path,
),
);
const path = parentPath ? `${parentPath}.${error.path}` : error.path;

return error.inner.flatMap((err) => issuesFromValidationError(err, path));
}

0 comments on commit 9ca5949

Please sign in to comment.