Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

FormValidators.md

184 lines4.5 KB

1---
2id: FormValidators
3title: FormValidators
4---
5​
6# Interface: FormValidators\<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync\>
7​
8Defined in: [packages/form-core/src/FormApi.ts:176](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L176)
9​
10## Type Parameters
11​
12### TFormData
13​
14`TFormData`
15​
16### TOnMount
17​
18`TOnMount` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
19​
20### TOnChange
21​
22`TOnChange` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
23​
24### TOnChangeAsync
25​
26`TOnChangeAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
27​
28### TOnBlur
29​
30`TOnBlur` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
31​
32### TOnBlurAsync
33​
34`TOnBlurAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
35​
36### TOnSubmit
37​
38`TOnSubmit` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
39​
40### TOnSubmitAsync
41​
42`TOnSubmitAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
43​
44### TOnDynamic
45​
46`TOnDynamic` *extends* `undefined` \| `FormValidateOrFn`\<`TFormData`\>
47​
48### TOnDynamicAsync
49​
50`TOnDynamicAsync` *extends* `undefined` \| `FormAsyncValidateOrFn`\<`TFormData`\>
51​
52## Properties
53​
54### onBlur?
55​
56```ts
57optional onBlur: TOnBlur;
58```
59​
60Defined in: [packages/form-core/src/FormApi.ts:207](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L207)
61​
62Optional function that validates the form data when a field loses focus, returns a `FormValidationError`
63​
64***
65​
66### onBlurAsync?
67​
68```ts
69optional onBlurAsync: TOnBlurAsync;
70```
71​
72Defined in: [packages/form-core/src/FormApi.ts:211](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L211)
73​
74Optional onBlur asynchronous validation method for when a field loses focus returns a ` FormValidationError` or a promise of `Promise<FormValidationError>`
75​
76***
77​
78### onBlurAsyncDebounceMs?
79​
80```ts
81optional onBlurAsyncDebounceMs: number;
82```
83​
84Defined in: [packages/form-core/src/FormApi.ts:215](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L215)
85​
86The default time in milliseconds that if set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds.
87​
88***
89​
90### onChange?
91​
92```ts
93optional onChange: TOnChange;
94```
95​
96Defined in: [packages/form-core/src/FormApi.ts:195](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L195)
97​
98Optional function that checks the validity of your data whenever a value changes
99​
100***
101​
102### onChangeAsync?
103​
104```ts
105optional onChangeAsync: TOnChangeAsync;
106```
107​
108Defined in: [packages/form-core/src/FormApi.ts:199](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L199)
109​
110Optional onChange asynchronous counterpart to onChange. Useful for more complex validation logic that might involve server requests.
111​
112***
113​
114### onChangeAsyncDebounceMs?
115​
116```ts
117optional onChangeAsyncDebounceMs: number;
118```
119​
120Defined in: [packages/form-core/src/FormApi.ts:203](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L203)
121​
122The default time in milliseconds that if set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds.
123​
124***
125​
126### onDynamic?
127​
128```ts
129optional onDynamic: TOnDynamic;
130```
131​
132Defined in: [packages/form-core/src/FormApi.ts:218](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L218)
133​
134***
135​
136### onDynamicAsync?
137​
138```ts
139optional onDynamicAsync: TOnDynamicAsync;
140```
141​
142Defined in: [packages/form-core/src/FormApi.ts:219](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L219)
143​
144***
145​
146### onDynamicAsyncDebounceMs?
147​
148```ts
149optional onDynamicAsyncDebounceMs: number;
150```
151​
152Defined in: [packages/form-core/src/FormApi.ts:220](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L220)
153​
154***
155​
156### onMount?
157​
158```ts
159optional onMount: TOnMount;
160```
161​
162Defined in: [packages/form-core/src/FormApi.ts:191](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L191)
163​
164Optional function that fires as soon as the component mounts.
165​
166***
167​
168### onSubmit?
169​
170```ts
171optional onSubmit: TOnSubmit;
172```
173​
174Defined in: [packages/form-core/src/FormApi.ts:216](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L216)
175​
176***
177​
178### onSubmitAsync?
179​
180```ts
181optional onSubmitAsync: TOnSubmitAsync;
182```
183​
184Defined in: [packages/form-core/src/FormApi.ts:217](https://github.com/TanStack/form/blob/main/packages/form-core/src/FormApi.ts#L217)