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
Joi validation works in code sandbox but not when running locally #4278
Comments
That doesn't really help us to investigate. You can try to create a repo and see if you can reproduce that. |
Here: https://github.com/juliushuck/issue-react-hook-form-joiresolver-v6 but it should be the same as the code sandbox i linked to |
Hi @juliushuck 👋🏻 Firstly, you can use After investigation, the problem schema seems not be in React Hook Form / @hookform/resolvers. You can try to validate your schema: try {
await schema.validateAsync(values);
} catch(e) {
// Got an error, but not the expected error, I think it's a Joi issue
} |
I'm now using joi directly, I also tried joi-browser but they both have kind of the following result. I tried your try-catch code. And it is catching nothing for me, BUT joi returns the error for the username. When I do That means, that joi is working, right? I also updated my repo, so its current code prints the error generated by joy in the console. |
Yes, it works with
Here is how I get the error: const { register, handleSubmit, errors } = useForm({
resolver: async (values) => {
try {
await schema.validateAsync(values); // For testing purpose
} catch(e) {
console.log(e); // Log the error
}
return await joiResolver(schema)(values);
},
}); Joi resolver uses |
Ok, then I will create an issue on the joi repo. |
Thanks very much @jorisre for looking into this. |
Describe the bug
To Reproduce
Steps to reproduce the behavior:
Codesandbox link (Required)
https://codesandbox.io/s/react-hook-form-joiresolver-v6-yejqe?file=/src/index.js
Expected behavior
Validation like in the code sandbox, username display in the alert
Screenshots
https://user-images.githubusercontent.com/41862965/109089198-2131e700-7711-11eb-8b2d-67eac4903038.mov
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: