Setup Errors

Setup Errors for the application


To simplify the process of converting errors from validation packages like joi, yup, zod, ajv, etc to useForm lookalike errors, use setDefaultOnError. You only need to setup this on the initialization of the application in this case App.tsx

setDefaultOnError will, by default (unless onError from Form Options is set), customize the errors to fit useForm errors

// In App.tsx
import { setDefaultOnError } from '@resourge/react-form'

setDefaultOnError((errors: any) => {
  // Customize errors to fit the model 
  // [{ path, errors }]
  return []
});