File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,13 @@ interface FormHelpers {
17
17
helperText ?: string
18
18
}
19
19
20
- export const getFormHelpers = < T > ( form : FormikContextType < T > , name : string , error ?: string ) : FormHelpers => {
21
- // getIn is a util function from Formik that gets at any depth of nesting, and is necessary for the types to work
20
+ export const getFormHelpers = < T > ( form : FormikContextType < T > , name : keyof T , error ?: string ) : FormHelpers => {
21
+ if ( typeof name !== "string" ) {
22
+ throw new Error ( `name must be type of string, instead received '${ typeof name } '` )
23
+ }
24
+
25
+ // getIn is a util function from Formik that gets at any depth of nesting
26
+ // and is necessary for the types to work
22
27
const touched = getIn ( form . touched , name )
23
28
const errors = error ?? getIn ( form . errors , name )
24
29
return {
You can’t perform that action at this time.
0 commit comments