1- import { FieldValues , useForm } from 'react-hook-form' ;
1+ import { FieldValues } from 'react-hook-form' ;
22
33/**
44 * Convert a simple validation function that returns an object matching the form shape with errors
@@ -31,7 +31,7 @@ export const getSimpleValidationResolver =
3131
3232 // If there are no errors, early return the form values
3333 if ( ! errors || isEmptyObject ( errors ) ) {
34- return { values : data as TFieldValues , errors : { } } ;
34+ return { values : data , errors : { } } ;
3535 }
3636
3737 // Else, we return an error object shaped like errors but having for each leaf
@@ -43,12 +43,12 @@ export const getSimpleValidationResolver =
4343 // e.g. with an ArrayInput we can get something like: `{backlinks: [{}, {}] }`
4444 // If, after transformation, there are no errors, we return the form values
4545 if ( ! transformedErrors || isEmptyObject ( transformedErrors ) ) {
46- return { values : data as TFieldValues , errors : { } } ;
46+ return { values : data , errors : { } } ;
4747 }
4848
4949 // Else return the errors and no values
5050 return {
51- values : { } as TFieldValues ,
51+ values : { } ,
5252 errors : transformedErrors ,
5353 } ;
5454 } ;
@@ -111,4 +111,4 @@ export type ValidateForm<TFieldValues extends FieldValues = FieldValues> = (
111111) =>
112112 | Partial < Record < keyof TFieldValues , any > >
113113 | undefined
114- | Promise < Partial < Record < keyof TFieldValues , any > > > ;
114+ | Promise < Partial < Record < keyof TFieldValues , any > > | undefined > ;
0 commit comments