Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom error messages can't be modified with ErrorMap #2492

Closed
vktrl opened this issue Jun 7, 2023 · 3 comments
Closed

Custom error messages can't be modified with ErrorMap #2492

vktrl opened this issue Jun 7, 2023 · 3 comments

Comments

@vktrl
Copy link

vktrl commented Jun 7, 2023

According to the documentation it should be possible to override all error messages, but it only works with custom errors only if the original message is undefined. Messages defined in refinements seem to be hardcoded and values returned by ErrorMap are ignored.

codesandbox example

@adamsujeta
Copy link

I have opened an issue in react-hook-form repo. I realized that it was a mistake and it is an problem with zod and not react-hook-form. I have exactly the same problem I would love to be able to override every possible error message with ErrorMap but it is not working. Any updates on the issue?

@colinhacks
Copy link
Owner

colinhacks commented Jul 30, 2023

I think the current priority order makes more sense. It would be very odd if the error map couldn't be overridden by a special case defined at the level of an individual schema.

cc @thomaswinckell

@vktrl
Copy link
Author

vktrl commented Aug 22, 2023

Ok, that makes sense.
What I was trying to do is to use the message field as a code that gets replaced by a localized message down the line by the client. Solved the issue by using params.

@vktrl vktrl closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants