Skip to content

Commit 1a248c9

Browse files
committed
chore: fix types
1 parent 7fbff96 commit 1a248c9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

packages/form-core/src/FormApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
standardSchemaValidators,
1919
} from './standardSchemaValidator'
2020
import { defaultFieldMeta, metaHelper } from './metaHelper'
21+
import type { ValidationLogicFn } from './ValidationLogic'
2122
import type {
2223
StandardSchemaV1,
2324
StandardSchemaV1Issue,
@@ -419,8 +420,7 @@ export interface FormOptions<
419420
TOnDynamicAsync
420421
>
421422

422-
// TODO: Type this properly
423-
validationLogic?: unknown
423+
validationLogic?: ValidationLogicFn
424424

425425
/**
426426
* form level listeners

packages/form-core/src/ValidationLogic.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { AnyFormApi, FormValidators } from './FormApi'
22

33
interface ValidationLogicValidatorsFn {
4-
fn: // TODO: Type this properly
5-
FormValidators<
4+
// TODO: Type this properly
5+
fn: FormValidators<
66
any,
77
any,
88
any,
@@ -53,6 +53,8 @@ interface RevalidateLogicProps {
5353
modeAfterSubmission?: 'change' | 'blur' | 'submit'
5454
}
5555

56+
export type ValidationLogicFn = (props: ValidationLogicProps) => void
57+
5658
/**
5759
* This forces a form's validation logic to be ran as if it were a React Hook Form validation logic.
5860
*
@@ -66,8 +68,8 @@ export const revalidateLogic =
6668
({
6769
mode = 'submit',
6870
modeAfterSubmission = 'change',
69-
}: RevalidateLogicProps = {}) =>
70-
(props: ValidationLogicProps) => {
71+
}: RevalidateLogicProps = {}): ValidationLogicFn =>
72+
(props) => {
7173
const validatorNames = Object.keys(props.validators ?? {})
7274
if (validatorNames.length === 0) {
7375
// No validators is a valid case, just return
@@ -115,7 +117,7 @@ export const revalidateLogic =
115117
})
116118
}
117119

118-
export function defaultValidationLogic(props: ValidationLogicProps) {
120+
export const defaultValidationLogic: ValidationLogicFn = (props) => {
119121
// Handle case where no validators are provided
120122
if (!props.validators) {
121123
return props.runValidation({

0 commit comments

Comments
 (0)