Open History to see the last commit
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.