-
Version Number^7.35.0 Codesandbox/Expo snackhttps://codesandbox.io/s/competent-ishizaka-mtfb6f?file=/src/Form.tsx Steps to reproduce
Please manage to find time to look into the issue. Expected behaviourThe custom error message i have defined in the schema definition "You must accept terms and conditions", should be thrown as message instead of the generic error message "Invalid literal value, expected true". What browsers are you seeing the problem on?No response Relevant log outputNo response Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
please try to debug yourself for this sort of question: resolver: async (data, context, options) => {
// you can debug your validation schema here
console.log('formData', data)
console.log('validation result', await anyResolver(schema)(data, context, options))
return anyResolver(schema)(data, context, options)
}, |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
@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