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

Validator.md

172 lines3.8 KB

Defined in: validation.public.ts:41

Configures validation for a form, form group, or field.

Extends

Extended by

Type Parameters

TFormData

TFormData

Library-managed. Do not specify explicitly.

TValidator

TValidator extends | StandardSchemaV1 | ValidatorFn<any, any>

Library-managed. Do not specify explicitly.

TContextValue

TContextValue

Library-managed. Do not specify explicitly.

TTrigger

TTrigger extends ValidatorTrigger = ValidatorTrigger

Library-managed. Do not specify explicitly.

TScope

TScope extends ValidatorScope = ValidatorScope

Library-managed. Do not specify explicitly.

Properties

bailIfInvalid?

optional bailIfInvalid?: boolean;

Defined in: validation.public.ts:29

If true, skips this and subsequent validators when earlier validation has failed.

If false, earlier failures do not prevent this validator from running.

Default

false

Inherited from

BaseValidator.bailIfInvalid


run

run: TValidator;

Defined in: validation.public.ts:21

The function or Standard Schema that validates the value in this validator's scope.

Inherited from

BaseValidator.run


runOnMount?

optional runOnMount?: boolean;

Defined in: validation.public.ts:64

Whether this validator runs when the form is constructed or when its field or form group first mounts.

Default

false

skipOnSubmit?

optional skipOnSubmit?: 
  | boolean
| ValidationPredicateFn<TFormData, TContextValue, TScope>;

Defined in: validation.public.ts:56

Whether this validator runs during a submission attempt, independently of triggers.

Pass a boolean directly, or pass a function that returns true to skip it for the current attempt.

Default

false

triggerDebounceMs?

optional triggerDebounceMs?: 
  | number
| ValidationDebounceFn<TFormData, TContextValue, TScope>;

Defined in: validation.public.ts:74

The delay in milliseconds before validation runs for change or blur events.

Pass a number for a fixed delay, or pass a function that returns the delay for the current event. Repeated events restart the delay. Submission validation runs immediately.

Default

0

triggers

triggers: ValidationTriggerOption<TFormData, TContextValue, TTrigger, TScope>[];

Defined in: validation.public.ts:82

Change and blur events that can run this validator, optionally with conditions.

An empty array disables change and blur validation. Configure submission separately with skipOnSubmit and initial validation with runOnMount.