Replies: 5 comments 4 replies
|
Instead of using plain message error on zod validation rule, you can use a translation key then just create an Error component that get the key and put it into translate function. For example: |
3 replies
|
Any progress? |
0 replies
|
need translated error messages for zod |
0 replies
|
If anyone stumbled upon this thread, this may be useful to you: https://github.com/orgs/react-hook-form/discussions/9452 (looks like possible solution is to pass t function to resolver function) ie: |
0 replies
|
Hello. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi there,
I'm trying to create a form handling layer in our app and have come across an issue which I could not find the solution for:
I want to be able to display translated error messages. All the examples that I saw up until now suggest that the formatted message for the end user, should come from the schema itself.
The common example that I have come across is something like the following:
In my case, I have to do something like this:
This has 2 big disadvantages: The schema cannot be reused outside of react, and the type cannot be auto-inferred and used in another module.
The ideal solution would be to get more information from FieldError in react-hook-form,
Right now, for this error I would get something like the following:
This is the data that zod provides:
Had I received the complete information from
zod, I could've translated the message properly. Which is impossible with the information fromFieldError.Any recommendations? Am I doing something wrong?
All reactions