From 9c2a970c7d612c9432db70a011663f3f241072ca Mon Sep 17 00:00:00 2001 From: Viren070 Date: Tue, 17 Jun 2025 17:38:58 +0100 Subject: [PATCH] feat: improve formatting of zod errors when using unions --- packages/core/src/utils/config.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/src/utils/config.ts b/packages/core/src/utils/config.ts index b4cd62c9..bb0f8e04 100644 --- a/packages/core/src/utils/config.ts +++ b/packages/core/src/utils/config.ts @@ -28,7 +28,15 @@ const logger = createLogger('core'); export const formatZodError = (error: ZodError) => { let errs = []; for (const issue of error.issues) { - errs.push(`Invalid value for ${issue.path.join('.')}: ${issue.message}`); + errs.push( + `Invalid value for ${issue.path.join('.')}: ${issue.message}${ + (issue as any).unionErrors + ? `. Union checks performed:\n${(issue as any).unionErrors + .map((issue: any) => `- ${formatZodError(issue)}`) + .join('\n')}` + : '' + }` + ); } return errs.join(' | '); };