When works with real application validations forms is very common because this is the way you can verify if the input's value is correct or not.
There are several validations solutions available, but when we use
useForm the default solution is Yup.With yup the process of validations is very simple and powerful.
The useform returns an error object, that has all errors, and this object is updated every time the input is changed or when the form is submitted if you are using an uncontrolled form.
It's important you remember that to show error the correct way you need knows if an input with error is touched or not. You can discover this information with an object called touched, this object has all properties the initial values object but instead of values, the object has a boolean value, this boolean value shows you if a specific input was touched.
The validation is runes every time the state is changed. By default, the
useForm uses the option uncontrolled inputs, it means that values are accessible when onSubmit event is dispatched.
usevalidation is a custom hook, every time the input value is changed that hook is called and udate object error. This hook makes the same work that
useForm makes, you can use this hook if you want to get more control about form validation.
This hook receives the values and a yup validation schema, and return the object errors.