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

fieldoptions.md

134 lines4.0 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\>
9​
10Defined in: [packages/form-core/src/FieldApi.ts:361](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L361)
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## Properties
41​
42### asyncAlways?
43​
44```ts
45optional asyncAlways: boolean;
46```
47​
48Defined in: [packages/form-core/src/FieldApi.ts:394](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L394)
49​
50If `true`, always run async validation, even if there are errors emitted during synchronous validation.
51​
52***
53​
54### asyncDebounceMs?
55​
56```ts
57optional asyncDebounceMs: number;
58```
59​
60Defined in: [packages/form-core/src/FieldApi.ts:390](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L390)
61​
62The default time to debounce async validation if there is not a more specific debounce time passed.
63​
64***
65​
66### defaultMeta?
67​
68```ts
69optional defaultMeta: Partial<FieldMeta<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, any, any, any, any, any, any, any>>;
70```
71​
72Defined in: [packages/form-core/src/FieldApi.ts:413](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L413)
73​
74An optional object with default metadata for the field.
75​
76***
77​
78### defaultValue?
79​
80```ts
81optional defaultValue: NoInfer<TData>;
82```
83​
84Defined in: [packages/form-core/src/FieldApi.ts:386](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L386)
85​
86An optional default value for the field.
87​
88***
89​
90### disableErrorFlat?
91​
92```ts
93optional disableErrorFlat: boolean;
94```
95​
96Defined in: [packages/form-core/src/FieldApi.ts:441](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L441)
97​
98Disable 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.
99​
100***
101​
102### listeners?
103​
104```ts
105optional listeners: FieldListeners<TParentData, TName, TData>;
106```
107​
108Defined in: [packages/form-core/src/FieldApi.ts:437](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L437)
109​
110A list of listeners which attach to the corresponding events
111​
112***
113​
114### name
115​
116```ts
117name: TName;
118```
119​
120Defined in: [packages/form-core/src/FieldApi.ts:382](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L382)
121​
122The field name. The type will be `DeepKeys<TParentData>` to ensure your name is a deep key of the parent dataset.
123​
124***
125​
126### validators?
127​
128```ts
129optional validators: FieldValidators<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync>;
130```
131​
132Defined in: [packages/form-core/src/FieldApi.ts:398](https://github.com/TanStack/form/blob/main/packages/form-core/src/FieldApi.ts#L398)
133​
134A list of validators to pass to the field