Hard
Your team is implementing a custom form validation library. Complete the missing code in this custom hook:
1function useFormValidation(initialValues, validationSchema) {2 const [values, setValues] = useState(initialValues);3 const [errors, setErrors] = useState({});4 const [touched, setTouched] = useState({});5 const validateRef = useRef(null);67 useEffect(() => {8 validateRef.current = debounce(async (fieldValues) => {9 try {10 // Missing validation logic here11 } catch (validationErrors) {12 // Missing error handling here13 }14 }, 300);15 }, [validationSchema]);1617 const handleChange = (event) => {18 const { name, value } = event.target;19 setValues(prev => ({20 ...prev,21 [name]: value22 }));23 validateRef.current?.(/* Missing argument */);24 };2526 return {27 values,28 errors,29 touched,30 handleChange,31 // ... rest of the implementation32 };33}