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

FormState.md

166 lines2.6 KB

1---
2id: FormState
3title: FormState
4---
5​
6# Type Alias: FormState\<TFormData\>
7​
8```ts
9type FormState<TFormData>: object;
10```
11​
12An object representing the current state of the form.
13​
14## Type Parameters
15​
16β€’ **TFormData**
17​
18## Type declaration
19​
20### canSubmit
21​
22```ts
23canSubmit: boolean;
24```
25​
26A boolean indicating if the form can be submitted based on its current state.
27​
28### errorMap
29​
30```ts
31errorMap: ValidationErrorMap;
32```
33​
34The error map for the form itself.
35​
36### errors
37​
38```ts
39errors: ValidationError[];
40```
41​
42The error array for the form itself.
43​
44### fieldMeta
45​
46```ts
47fieldMeta: Record<DeepKeys<TFormData>, FieldMeta>;
48```
49​
50A record of field metadata for each field in the form.
51​
52### isDirty
53​
54```ts
55isDirty: boolean;
56```
57​
58A boolean indicating if any of the form's fields' values have been modified by the user. `True` if the user have modified at least one of the fields. Opposite of `isPristine`.
59​
60### isFieldsValid
61​
62```ts
63isFieldsValid: boolean;
64```
65​
66A boolean indicating if all the form fields are valid.
67​
68### isFieldsValidating
69​
70```ts
71isFieldsValidating: boolean;
72```
73​
74A boolean indicating if any of the form fields are currently validating.
75​
76### isFormValid
77​
78```ts
79isFormValid: boolean;
80```
81​
82A boolean indicating if the form is valid.
83​
84### isFormValidating
85​
86```ts
87isFormValidating: boolean;
88```
89​
90A boolean indicating if the form is currently validating.
91​
92### isPristine
93​
94```ts
95isPristine: boolean;
96```
97​
98A boolean indicating if none of the form's fields' values have been modified by the user. `True` if the user have not modified any of the fields. Opposite of `isDirty`.
99​
100### isSubmitted
101​
102```ts
103isSubmitted: boolean;
104```
105​
106A boolean indicating if the form has been submitted.
107​
108### isSubmitting
109​
110```ts
111isSubmitting: boolean;
112```
113​
114A boolean indicating if the form is currently submitting.
115​
116### isTouched
117​
118```ts
119isTouched: boolean;
120```
121​
122A boolean indicating if any of the form fields have been touched.
123​
124### isValid
125​
126```ts
127isValid: boolean;
128```
129​
130A boolean indicating if the form and all its fields are valid.
131​
132### isValidating
133​
134```ts
135isValidating: boolean;
136```
137​
138A boolean indicating if the form or any of its fields are currently validating.
139​
140### submissionAttempts
141​
142```ts
143submissionAttempts: number;
144```
145​
146A counter for tracking the number of submission attempts.
147​
148### validationMetaMap
149​
150```ts
151validationMetaMap: Record<ValidationErrorMapKeys, ValidationMeta | undefined>;
152```
153​
154An internal mechanism used for keeping track of validation logic in a form.
155​
156### values
157​
158```ts
159values: TFormData;
160```
161​
162The current values of the form fields.
163​
164## Defined in
165​
166[packages/form-core/src/FormApi.ts:198](https://github.com/TanStack/form/blob/a6313b7699753752ae30ff16c169e0b08c2369e8/packages/form-core/src/FormApi.ts#L198)