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

TanStackField.md

277 lines6.1 KB

1---
2id: TanStackField
3title: TanStackField
4---
5​
6# Class: TanStackField\<TParentData, TName, TFieldValidator, TFormValidator, TData\>
7​
8## Type Parameters
9​
10β€’ **TParentData**
11​
12β€’ **TName** *extends* `DeepKeys`\<`TParentData`\>
13​
14β€’ **TFieldValidator** *extends* `Validator`\<`DeepValue`\<`TParentData`, `TName`\>, `unknown`\> \| `undefined` = `undefined`
15​
16β€’ **TFormValidator** *extends* `Validator`\<`TParentData`, `unknown`\> \| `undefined` = `undefined`
17​
18β€’ **TData** *extends* `DeepValue`\<`TParentData`, `TName`\> = `DeepValue`\<`TParentData`, `TName`\>
19​
20## Implements
21​
22- `OnInit`
23- `OnChanges`
24- `OnDestroy`
25- `FieldOptions`\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>
26​
27## Constructors
28​
29### new TanStackField()
30​
31```ts
32new TanStackField<TParentData, TName, TFieldValidator, TFormValidator, TData>(): TanStackField<TParentData, TName, TFieldValidator, TFormValidator, TData>
33```
34​
35#### Returns
36​
37[`TanStackField`](TanStackField.md)\<`TParentData`, `TName`, `TFieldValidator`, `TFormValidator`, `TData`\>
38​
39## Properties
40​
41### api
42​
43```ts
44api: FieldApi<TParentData, TName, TFieldValidator, TFormValidator, TData>;
45```
46​
47#### Defined in
48​
49[tanstack-field.directive.ts:61](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L61)
50​
51***
52​
53### asyncAlways?
54​
55```ts
56optional asyncAlways: boolean;
57```
58​
59If `true`, always run async validation, even if there are errors emitted during synchronous validation.
60​
61#### Implementation of
62​
63`FieldOptions.asyncAlways`
64​
65#### Defined in
66​
67[tanstack-field.directive.ts:50](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L50)
68​
69***
70​
71### asyncDebounceMs?
72​
73```ts
74optional asyncDebounceMs: number;
75```
76​
77The default time to debounce async validation if there is not a more specific debounce time passed.
78​
79#### Implementation of
80​
81`FieldOptions.asyncDebounceMs`
82​
83#### Defined in
84​
85[tanstack-field.directive.ts:49](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L49)
86​
87***
88​
89### defaultMeta?
90​
91```ts
92optional defaultMeta: Partial<FieldMeta>;
93```
94​
95An optional object with default metadata for the field.
96​
97#### Implementation of
98​
99`FieldOptions.defaultMeta`
100​
101#### Defined in
102​
103[tanstack-field.directive.ts:59](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L59)
104​
105***
106​
107### defaultValue?
108​
109```ts
110optional defaultValue: NoInfer<TData>;
111```
112​
113An optional default value for the field.
114​
115#### Implementation of
116​
117`FieldOptions.defaultValue`
118​
119#### Defined in
120​
121[tanstack-field.directive.ts:48](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L48)
122​
123***
124​
125### name
126​
127```ts
128name: TName;
129```
130​
131The field name. The type will be `DeepKeys<TParentData>` to ensure your name is a deep key of the parent dataset.
132​
133#### Implementation of
134​
135`FieldOptions.name`
136​
137#### Defined in
138​
139[tanstack-field.directive.ts:44](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L44)
140​
141***
142​
143### tanstackField
144​
145```ts
146tanstackField: FormApi<TParentData, TFormValidator>;
147```
148​
149#### Defined in
150​
151[tanstack-field.directive.ts:52](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L52)
152​
153***
154​
155### unmount()?
156​
157```ts
158optional unmount: () => void;
159```
160​
161#### Returns
162​
163`void`
164​
165#### Defined in
166​
167[tanstack-field.directive.ts:76](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L76)
168​
169***
170​
171### validatorAdapter?
172​
173```ts
174optional validatorAdapter: TFieldValidator;
175```
176​
177A validator provided by an extension, like `yupValidator` from `@tanstack/yup-form-adapter`
178​
179#### Implementation of
180​
181`FieldOptions.validatorAdapter`
182​
183#### Defined in
184​
185[tanstack-field.directive.ts:51](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L51)
186​
187***
188​
189### validators?
190​
191```ts
192optional validators: NoInfer<FieldValidators<TParentData, TName, TFieldValidator, TFormValidator, TData>>;
193```
194​
195A list of validators to pass to the field
196​
197#### Implementation of
198​
199`FieldOptions.validators`
200​
201#### Defined in
202​
203[tanstack-field.directive.ts:56](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L56)
204​
205## Methods
206​
207### ngOnChanges()
208​
209```ts
210ngOnChanges(): void
211```
212​
213A callback method that is invoked immediately after the
214default change detector has checked data-bound properties
215if at least one has changed, and before the view and content
216children are checked.
217​
218#### Returns
219​
220`void`
221​
222#### Implementation of
223​
224`OnChanges.ngOnChanges`
225​
226#### Defined in
227​
228[tanstack-field.directive.ts:88](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L88)
229​
230***
231​
232### ngOnDestroy()
233​
234```ts
235ngOnDestroy(): void
236```
237​
238A callback method that performs custom clean-up, invoked immediately
239before a directive, pipe, or service instance is destroyed.
240​
241#### Returns
242​
243`void`
244​
245#### Implementation of
246​
247`OnDestroy.ngOnDestroy`
248​
249#### Defined in
250​
251[tanstack-field.directive.ts:84](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L84)
252​
253***
254​
255### ngOnInit()
256​
257```ts
258ngOnInit(): void
259```
260​
261A callback method that is invoked immediately after the
262default change detector has checked the directive's
263data-bound properties for the first time,
264and before any of the view or content children have been checked.
265It is invoked only once when the directive is instantiated.
266​
267#### Returns
268​
269`void`
270​
271#### Implementation of
272​
273`OnInit.ngOnInit`
274​
275#### Defined in
276​
277[tanstack-field.directive.ts:78](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/angular-form/src/tanstack-field.directive.ts#L78)