Valibot schema validation #10724
-
There is a new, lighterweight alternative to zod that has just been released, called Valibot. https://www.builder.io/blog/introducing-valibot. What would it take to be able to use their schemas with react-hook-form? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
One approach (on a per-form basis) would be to follow the example in the RHF docs: https://react-hook-form.com/advanced-usage#CustomHookwithResolver (They used Yup in the example, but you could code it with whatever validation logic you want.) A more comprehensive approach would be to implement your own resolver so that it can be reused. The existing ones all live in the "@hookform/resolvers" package on GitHub: https://github.com/react-hook-form/resolvers I didn't see any specific how-to instructions for building one, but there's lots of examples there. |
Beta Was this translation helpful? Give feedback.
Well, it does have a
valibot
resolver.