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

fieldoptions.md

138 lines4.3 KB

1---
2id: FieldOptions
3title: FieldOptions
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8# Interface: FieldOptions\<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync\>
9​
10Defined in: [packages/form-core/src/FieldApi.ts:390](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L390)
11​
12An object type representing the options for a field in a form.
13​
14## Extended by
15​
16- [`FieldApiOptions`](../fieldapioptions.md)
17​
18## Type Parameters
19​
20β€’ **TParentData**
21​
22β€’ **TName** *extends* [`DeepKeys`](../../type-aliases/deepkeys.md)\<`TParentData`\>
23​
24β€’ **TData** *extends* [`DeepValue`](../../type-aliases/deepvalue.md)\<`TParentData`, `TName`\>
25​
26β€’ **TOnMount** *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
27​
28β€’ **TOnChange** *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
29​
30β€’ **TOnChangeAsync** *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
31​
32β€’ **TOnBlur** *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
33​
34β€’ **TOnBlurAsync** *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
35​
36β€’ **TOnSubmit** *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
37​
38β€’ **TOnSubmitAsync** *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
39​
40β€’ **TOnDynamic** *extends* `undefined` \| `FieldValidateOrFn`\<`TParentData`, `TName`, `TData`\>
41​
42β€’ **TOnDynamicAsync** *extends* `undefined` \| `FieldAsyncValidateOrFn`\<`TParentData`, `TName`, `TData`\>
43​
44## Properties
45​
46### asyncAlways?
47​
48```ts
49optional asyncAlways: boolean;
50```
51​
52Defined in: [packages/form-core/src/FieldApi.ts:427](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L427)
53​
54If `true`, always run async validation, even if there are errors emitted during synchronous validation.
55​
56***
57​
58### asyncDebounceMs?
59​
60```ts
61optional asyncDebounceMs: number;
62```
63​
64Defined in: [packages/form-core/src/FieldApi.ts:423](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L423)
65​
66The default time to debounce async validation if there is not a more specific debounce time passed.
67​
68***
69​
70### defaultMeta?
71​
72```ts
73optional defaultMeta: Partial<FieldMeta<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, any, any, any, any, any, any, any, any, any>>;
74```
75​
76Defined in: [packages/form-core/src/FieldApi.ts:448](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L448)
77​
78An optional object with default metadata for the field.
79​
80***
81​
82### defaultValue?
83​
84```ts
85optional defaultValue: NoInfer<TData>;
86```
87​
88Defined in: [packages/form-core/src/FieldApi.ts:419](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L419)
89​
90An optional default value for the field.
91​
92***
93​
94### disableErrorFlat?
95​
96```ts
97optional disableErrorFlat: boolean;
98```
99​
100Defined in: [packages/form-core/src/FieldApi.ts:480](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L480)
101​
102Disable 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.
103​
104***
105​
106### listeners?
107​
108```ts
109optional listeners: FieldListeners<TParentData, TName, TData>;
110```
111​
112Defined in: [packages/form-core/src/FieldApi.ts:476](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L476)
113​
114A list of listeners which attach to the corresponding events
115​
116***
117​
118### name
119​
120```ts
121name: TName;
122```
123​
124Defined in: [packages/form-core/src/FieldApi.ts:415](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L415)
125​
126The field name. The type will be `DeepKeys<TParentData>` to ensure your name is a deep key of the parent dataset.
127​
128***
129​
130### validators?
131​
132```ts
133optional validators: FieldValidators<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync>;
134```
135​
136Defined in: [packages/form-core/src/FieldApi.ts:431](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L431)
137​
138A list of validators to pass to the field