File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
18
18
standardSchemaValidators ,
19
19
} from './standardSchemaValidator'
20
20
import { defaultFieldMeta , metaHelper } from './metaHelper'
21
+ import type { ValidationLogicFn } from './ValidationLogic'
21
22
import type {
22
23
StandardSchemaV1 ,
23
24
StandardSchemaV1Issue ,
@@ -419,8 +420,7 @@ export interface FormOptions<
419
420
TOnDynamicAsync
420
421
>
421
422
422
- // TODO: Type this properly
423
- validationLogic ?: unknown
423
+ validationLogic ?: ValidationLogicFn
424
424
425
425
/**
426
426
* form level listeners
Original file line number Diff line number Diff line change 1
1
import type { AnyFormApi , FormValidators } from './FormApi'
2
2
3
3
interface ValidationLogicValidatorsFn {
4
- fn : // TODO: Type this properly
5
- FormValidators <
4
+ // TODO: Type this properly
5
+ fn : FormValidators <
6
6
any ,
7
7
any ,
8
8
any ,
@@ -53,6 +53,8 @@ interface RevalidateLogicProps {
53
53
modeAfterSubmission ?: 'change' | 'blur' | 'submit'
54
54
}
55
55
56
+ export type ValidationLogicFn = ( props : ValidationLogicProps ) => void
57
+
56
58
/**
57
59
* This forces a form's validation logic to be ran as if it were a React Hook Form validation logic.
58
60
*
@@ -66,8 +68,8 @@ export const revalidateLogic =
66
68
( {
67
69
mode = 'submit' ,
68
70
modeAfterSubmission = 'change' ,
69
- } : RevalidateLogicProps = { } ) =>
70
- ( props : ValidationLogicProps ) => {
71
+ } : RevalidateLogicProps = { } ) : ValidationLogicFn =>
72
+ ( props ) => {
71
73
const validatorNames = Object . keys ( props . validators ?? { } )
72
74
if ( validatorNames . length === 0 ) {
73
75
// No validators is a valid case, just return
@@ -115,7 +117,7 @@ export const revalidateLogic =
115
117
} )
116
118
}
117
119
118
- export function defaultValidationLogic ( props : ValidationLogicProps ) {
120
+ export const defaultValidationLogic : ValidationLogicFn = ( props ) => {
119
121
// Handle case where no validators are provided
120
122
if ( ! props . validators ) {
121
123
return props . runValidation ( {
You can’t perform that action at this time.
0 commit comments