Created
June 8, 2023 15:30
-
-
Save manavm1990/ed5a5b8a7f8f13c30c3ce6066da9263d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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