mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
feat: improve formatting of zod errors when using unions
This commit is contained in:
@@ -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(' | ');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user