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

createErrorMap.md

40 lines1.1 KB

function createErrorMap<TFormData>(initial?): ValidationErrorMap<TFormData>;

Defined in: validation.public.ts:615

Creates a mutable map of form errors and errors for individual field paths.

Pass the completed map back from a form or group validator to report the errors.

Type Parameters

TFormData

TFormData

The form or group value shape whose field paths are accepted by the map. Specify it when calling this helper directly to restrict fields to that shape's paths. Without a known value shape, field paths are unrestricted. The validator context's createErrorMap already uses the form or group shape and needs no type argument.

Parameters

initial?

Partial<ValidationErrorMap<TFormData>>

An existing map to reuse. A missing fields object is added to it.

Returns

ValidationErrorMap<TFormData>

The initial map, if supplied, or a new map with an empty fields object.