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

FieldValidator.md

188 lines4.3 KB

Defined in: validation.public.ts:983

Configures validation of a field's value, optionally reacting to related fields.

Extends

Type Parameters

TFormData

TFormData

Library-managed. Do not specify explicitly.

TFieldName

TFieldName

Library-managed. Do not specify explicitly.

TFieldValue

TFieldValue

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

Validator.bailIfInvalid


run

run: 
  | FieldValidatorFn<TFormData, TFieldName, TFieldValue>
| StandardSchemaV1<TFieldValue, any>;

Defined in: validation.public.ts:21

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

Inherited from

Validator.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

Inherited from

Validator.runOnMount


skipOnSubmit?

optional skipOnSubmit?: 
  | boolean
| ValidationPredicateFn<TFormData, TFieldValue, "field">;

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

Inherited from

Validator.skipOnSubmit


triggerDebounceMs?

optional triggerDebounceMs?: 
  | number
| ValidationDebounceFn<TFormData, TFieldValue, "field">;

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

Inherited from

Validator.triggerDebounceMs


triggers

triggers: ValidationTriggerOption<TFormData, TFieldValue, ConfigurableValidationTrigger, "field">[];

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.

Inherited from

Validator.triggers


watchFields?

optional watchFields?: DeepKeys<TFormData>[];

Defined in: validation.public.ts:1001

Other field paths whose change or blur events can run this validator.

Events must still match an enabled entry in triggers. The validator receives its own field's value, even when a watched field caused the event.