Hello everyone
I using the useForm to work a create user issue, but i wanna add a validation schema with yup, but i cant find info about it, someone can help me?
2 Replies
Hi @mauryo. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Sure, I can help you with that. To use a validation schema with yup in your form, you need to follow these steps:
1. First, install the
yup
and the @hookform/resolvers
libraries using the following command:
2. Once the installation is done, import yup
and yupResolver
and create a schema object with the following keys and values:
3. Finally, add a resolver key to the useForm object and pass the yupResolver function and schema to it as a value:
That's it! Now your form will validate the input fields based on the rules defined in the schema.
For more information, you can refer to this blog post (https://refine.dev/blog/react-hook-form-validation-examples#schema-validation) on the Refine website.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@737073867532796026> kapa.ai is still learning and improving, please let us know how it did by reacting below