Skip to content

issue: Schema validation using zod: Custom error message is not show instead generic error message is shown #9063

Answered by leapful
bicky-tmg asked this question in Q&A
Discussion options

You must be logged in to vote

@bicky-tmg

This is not an issue from react-hook-form. It's from library zod where "zod.literal" does not accept custom message via "invalid_type_error" option.

Switch to "errorMap" will solve the issue.

Working demo: https://codesandbox.io/s/falling-sky-iu5g6u?file=/src/Form.tsx

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@bluebill1049
Comment options

@bicky-tmg
Comment options

@freddiemixell
Comment options

@mohammadkhakshoor
Comment options

Answer selected by bluebill1049
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #9062 on September 19, 2022 09:41.