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

FormValidatorContext.md

130 lines2.9 KB

1---
2id: FormValidatorContext
3title: FormValidatorContext
4---
5​
6Defined in: [validation.public.ts:711](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L711)
7​
8Values and helpers passed to a form validation function.
9​
10## Type Parameters
11​
12### TFormData
13​
14`TFormData`
15​
16Library-managed. Do not specify explicitly.
17​
18## Properties
19​
20### createErrorMap
21​
22```ts
23createErrorMap: (initial?) => ValidationErrorMap<TFormData>;
24```
25​
26Defined in: [validation.public.ts:725](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L725)
27​
28Creates an error map with field paths inferred from the form values.
29​
30Creates a mutable map of form errors and errors for individual field paths.
31​
32Pass the completed map back from a form or group validator to report the errors.
33​
34#### Parameters
35​
36##### initial?
37​
38`Partial`\<[`ValidationErrorMap`](ValidationErrorMap.md)\<`TFormData`\>\>
39​
40An existing map to reuse. A missing `fields` object is added to it.
41​
42#### Returns
43​
44[`ValidationErrorMap`](ValidationErrorMap.md)\<`TFormData`\>
45​
46The initial map, if supplied, or a new map with an empty `fields` object.
47​
48***
49​
50### createOutput
51​
52```ts
53createOutput: CreateOutputFn;
54```
55​
56Defined in: [validation.public.ts:727](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L727)
57​
58Creates a successful result to return data in this validator's `validatorOutputs` entry.
59​
60***
61​
62### event
63​
64```ts
65event: ValidationTrigger | "server";
66```
67​
68Defined in: [validation.public.ts:713](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L713)
69​
70The event that caused this validation run.
71​
72***
73​
74### formApi
75​
76```ts
77formApi: FormApi<TFormData, any> | undefined;
78```
79​
80Defined in: [validation.public.ts:717](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L717)
81​
82The owning form on the client. `undefined` during server validation.
83​
84***
85​
86### parseIssues
87​
88```ts
89parseIssues: ParseFormIssuesFn<TFormData>;
90```
91​
92Defined in: [validation.public.ts:723](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L723)
93​
94Converts Standard Schema issues into form and field errors to return from this validator.
95​
96***
97​
98### signal
99​
100```ts
101signal: AbortSignal;
102```
103​
104Defined in: [validation.public.ts:715](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L715)
105​
106Aborted when this run is cancelled. Pass it to asynchronous work such as `fetch`.
107​
108***
109​
110### triggerFieldApi?
111​
112```ts
113optional triggerFieldApi?: AnyFieldApi;
114```
115​
116Defined in: [validation.public.ts:719](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L719)
117​
118The field that caused validation, when available.
119​
120***
121​
122### value
123​
124```ts
125value: TFormData;
126```
127​
128Defined in: [validation.public.ts:721](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L721)
129​
130The complete form values being validated.