-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[BUG] UseStepForm from headless not working with zod #6660
Comments
Just take one of the website examples: https://refine.dev/docs/packages/react-hook-form/use-steps-form/, then add zod resolver to it and create a zod scheme. You will see that you cannot go to the next page. |
Hello @BlackBearFTW, thanks for the issue. This bug occurs because when creating Right now, the core team's schedule is packed with Refine AI, but I'll try to find time to look into this bug next month. Of course, we'd be more than happy if anyone wants to work on it in the meantime! 🙌 |
@alicanerdurmaz even if you set the default value to "" and add another piece of validation (e.g. .min(1)) it will fail again. This is because unlike the UI packages, zod tries to validate the entire schema at once, where as the UI packages validate inline, meaning that they only validate the rendered fields. Now this breaks the form since when you go to the next step it tries to run the zod validator, which fails and then doesn't allow you to go to the next step. The only way this can be fixed is if you can somehow pass in a separate schema per step and it validates the scheme specific for that step. |
Another way that could work is if we can somehow only validate specific fields and you're able to pass in what fields you want to validate per step |
Describe the bug
Hi,
I was trying to use the use-step -form from
@refinedev/react-hook-form
, however this doesn't properly work with zod validation. When you add validation, it will fail the validation since there aren't any values for the next steps yet, since that part of the form hasn't been filled in. However you cannot go to the next step when validation failed, so you are just stuck on the first step.Steps To Reproduce
@refinedev/react-hook-form
there with zod and zodResolverExpected behavior
Should only validate inputs visible in current step
Packages
@refinedev/react-hook-form
Additional Context
No response
The text was updated successfully, but these errors were encountered: