Skip to content

Instantly share code, notes, and snippets.

@manavm1990
Created June 8, 2023 15:30
Show Gist options
  • Save manavm1990/ed5a5b8a7f8f13c30c3ce6066da9263d to your computer and use it in GitHub Desktop.
Save manavm1990/ed5a5b8a7f8f13c30c3ce6066da9263d to your computer and use it in GitHub Desktop.
import { type ZodError } from 'zod';
export const stringifyZodError = (error: ZodError): string => {
return error.issues
.map((issue) => {
const path = issue.path.join('.');
const message = issue.message;
return `Currently facing issue with the field "${path}". ${message}`;
})
.join('\n');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment