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

FormGroupValidator.md

161 lines3.7 KB

1---
2id: FormGroupValidator
3title: FormGroupValidator
4---
5​
6Defined in: [validation.public.ts:918](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L918)
7​
8Configures validation of a form group's value.
9​
10## Extends
11​
12- [`Validator`](Validator.md)\<`TGroupValue`,
13 \| [`FormGroupValidatorFn`](../type-aliases/FormGroupValidatorFn.md)\<`TGroupValue`\>
14 \| [`StandardSchemaV1`](../type-aliases/StandardSchemaV1.md)\<`TGroupValue`, `any`\>, `TGroupValue`, [`ConfigurableValidationTrigger`](../type-aliases/ConfigurableValidationTrigger.md), `"group"`\>
15​
16## Type Parameters
17​
18### TGroupValue
19​
20`TGroupValue`
21​
22Library-managed. Do not specify explicitly.
23​
24## Properties
25​
26### bailIfInvalid?
27​
28```ts
29optional bailIfInvalid?: boolean;
30```
31​
32Defined in: [validation.public.ts:29](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L29)
33​
34If `true`, skips this and subsequent validators when earlier validation has failed.
35​
36If `false`, earlier failures do not prevent this validator from running.
37​
38#### Default
39​
40```ts
41false
42```
43​
44#### Inherited from
45​
46[`Validator`](Validator.md).[`bailIfInvalid`](Validator.md#bailifinvalid)
47​
48***
49​
50### run
51​
52```ts
53run:
54 | FormGroupValidatorFn<TGroupValue>
55| StandardSchemaV1<TGroupValue, any>;
56```
57​
58Defined in: [validation.public.ts:21](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L21)
59​
60The function or Standard Schema that validates the value in this validator's scope.
61​
62#### Inherited from
63​
64[`Validator`](Validator.md).[`run`](Validator.md#run)
65​
66***
67​
68### runOnMount?
69​
70```ts
71optional runOnMount?: boolean;
72```
73​
74Defined in: [validation.public.ts:64](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L64)
75​
76Whether this validator runs when the form is constructed or when its field
77or form group first mounts.
78​
79#### Default
80​
81```ts
82false
83```
84​
85#### Inherited from
86​
87[`Validator`](Validator.md).[`runOnMount`](Validator.md#runonmount)
88​
89***
90​
91### skipOnSubmit?
92​
93```ts
94optional skipOnSubmit?:
95 | boolean
96| ValidationPredicateFn<TGroupValue, TGroupValue, "group">;
97```
98​
99Defined in: [validation.public.ts:56](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L56)
100​
101Whether this validator runs during a submission attempt, independently of `triggers`.
102​
103Pass a boolean directly, or pass a function that returns
104`true` to skip it for the current attempt.
105​
106#### Default
107​
108```ts
109false
110```
111​
112#### Inherited from
113​
114[`Validator`](Validator.md).[`skipOnSubmit`](Validator.md#skiponsubmit)
115​
116***
117​
118### triggerDebounceMs?
119​
120```ts
121optional triggerDebounceMs?:
122 | number
123| ValidationDebounceFn<TGroupValue, TGroupValue, "group">;
124```
125​
126Defined in: [validation.public.ts:74](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L74)
127​
128The delay in milliseconds before validation runs for change or blur events.
129​
130Pass a number for a fixed delay, or pass a function that returns the delay
131for the current event. Repeated events restart the delay.
132Submission validation runs immediately.
133​
134#### Default
135​
136```ts
138```
139​
140#### Inherited from
141​
142[`Validator`](Validator.md).[`triggerDebounceMs`](Validator.md#triggerdebouncems)
143​
144***
145​
146### triggers
147​
148```ts
149triggers: ValidationTriggerOption<TGroupValue, TGroupValue, ConfigurableValidationTrigger, "group">[];
150```
151​
152Defined in: [validation.public.ts:82](https://github.com/TanStack/form/blob/main/packages/form-core/src/validation.public.ts#L82)
153​
154Change and blur events that can run this validator, optionally with conditions.
155​
156An empty array disables change and blur validation. Configure submission
157separately with `skipOnSubmit` and initial validation with `runOnMount`.
158​
159#### Inherited from
160​
161[`Validator`](Validator.md).[`triggers`](Validator.md#triggers)