doug4794 - I have this login schema and want to...
I have this login schema and want to display my own error message.
Problem is that the schema is initialized before
i18n
. That's why the translation is wrong.
Is there a way to asynchronously fetch the message string (with a function or so)?
I know it's possible to do with refinement
but I want to have it only on the min()
validator and not on the whole thing.4 Replies
don't think it's possible to pass a function as a message nope
so you'd indeed need to make sure it's initialised after i18..
I feel like this question has been asked here before? 🤔
But no, the current way to change error messages is to use an error map, which you can set up globally, per parse, or per schema.
https://zod.dev/ERROR_HANDLING
GitHub
TypeScript-first schema validation with static type inference
TypeScript-first schema validation with static type inference
Ok thank you, maybe I'll create a GitHub issue then.