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

FieldOptions.md

160 lines4.3 KB

1---
2id: FieldOptions
3title: FieldOptions
4---
5​
6# Interface: FieldOptions\<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync\>
7​
8Defined in: [packages/form-core/src/FieldApi.ts:392](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L392)
9​
10An object type representing the options for a field in a form.
11​
12## Extended by
13​
14- [`FieldApiOptions`](FieldApiOptions.md)
15​
16## Type Parameters
17​
18### TParentData
19​
20`TParentData`
21​
22### TName
23​
24`TName` *extends* [`DeepKeys`](../type-aliases/DeepKeys.md)\<`TParentData`\>
25​
26### TData
27​
28`TData` *extends* [`DeepValue`](../type-aliases/DeepValue.md)\<`TParentData`, `TName`\>
29​
30### TOnMount
31​
32`TOnMount` *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
33​
34### TOnChange
35​
36`TOnChange` *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
37​
38### TOnChangeAsync
39​
40`TOnChangeAsync` *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
41​
42### TOnBlur
43​
44`TOnBlur` *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
45​
46### TOnBlurAsync
47​
48`TOnBlurAsync` *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
49​
50### TOnSubmit
51​
52`TOnSubmit` *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
53​
54### TOnSubmitAsync
55​
56`TOnSubmitAsync` *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
57​
58### TOnDynamic
59​
60`TOnDynamic` *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
61​
62### TOnDynamicAsync
63​
64`TOnDynamicAsync` *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
65​
66## Properties
67​
68### asyncAlways?
69​
70```ts
71optional asyncAlways: boolean;
72```
73​
74Defined in: [packages/form-core/src/FieldApi.ts:429](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L429)
75​
76If `true`, always run async validation, even if there are errors emitted during synchronous validation.
77​
78***
79​
80### asyncDebounceMs?
81​
82```ts
83optional asyncDebounceMs: number;
84```
85​
86Defined in: [packages/form-core/src/FieldApi.ts:425](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L425)
87​
88The default time to debounce async validation if there is not a more specific debounce time passed.
89​
90***
91​
92### defaultMeta?
93​
94```ts
95optional defaultMeta: Partial<FieldMeta<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, any, any, any, any, any, any, any, any, any>>;
96```
97​
98Defined in: [packages/form-core/src/FieldApi.ts:450](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L450)
99​
100An optional object with default metadata for the field.
101​
102***
103​
104### defaultValue?
105​
106```ts
107optional defaultValue: NoInfer<TData>;
108```
109​
110Defined in: [packages/form-core/src/FieldApi.ts:421](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L421)
111​
112An optional default value for the field.
113​
114***
115​
116### disableErrorFlat?
117​
118```ts
119optional disableErrorFlat: boolean;
120```
121​
122Defined in: [packages/form-core/src/FieldApi.ts:482](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L482)
123​
124Disable the `flat(1)` operation on `field.errors`. This is useful if you want to keep the error structure as is. Not suggested for most use-cases.
125​
126***
127​
128### listeners?
129​
130```ts
131optional listeners: FieldListeners<TParentData, TName, TData>;
132```
133​
134Defined in: [packages/form-core/src/FieldApi.ts:478](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L478)
135​
136A list of listeners which attach to the corresponding events
137​
138***
139​
140### name
141​
142```ts
143name: TName;
144```
145​
146Defined in: [packages/form-core/src/FieldApi.ts:417](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L417)
147​
148The field name. The type will be `DeepKeys<TParentData>` to ensure your name is a deep key of the parent dataset.
149​
150***
151​
152### validators?
153​
154```ts
155optional validators: FieldValidators<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync>;
156```
157​
158Defined in: [packages/form-core/src/FieldApi.ts:433](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L433)
159​
160A list of validators to pass to the field