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

createErrorMap.md

40 lines1.1 KB

1---
2id: createErrorMap
3title: createErrorMap
4---
5​
6```ts
7function createErrorMap<TFormData>(initial?): ValidationErrorMap<TFormData>;
8```
9​
10Defined in: [validation.public.ts:615](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L615)
11​
12Creates a mutable map of form errors and errors for individual field paths.
13​
14Pass the completed map back from a form or group validator to report the errors.
15​
16## Type Parameters
17​
18### TFormData
19​
20`TFormData`
21​
22The form or group value shape whose field paths are
23accepted by the map. Specify it when calling this helper directly to restrict
24`fields` to that shape's paths. Without a known value shape, field paths are
25unrestricted. The validator context's `createErrorMap` already uses the form
26or group shape and needs no type argument.
27​
28## Parameters
29​
30### initial?
31​
32`Partial`\<[`ValidationErrorMap`](../interfaces/ValidationErrorMap.md)\<`TFormData`\>\>
33​
34An existing map to reuse. A missing `fields` object is added to it.
35​
36## Returns
37​
38[`ValidationErrorMap`](../interfaces/ValidationErrorMap.md)\<`TFormData`\>
39​
40The initial map, if supplied, or a new map with an empty `fields` object.