TanStackForm v0
Auto

FieldValidators

Interface: FieldValidators<TParentData, TName, TFieldValidator, TFormValidator, TData>

Defined in: packages/form-core/src/FieldApi.ts:119

Type Parameters

TParentData

TName extends DeepKeys<TParentData>

TFieldValidator extends | Validator<DeepValue<TParentData, TName>, unknown> | undefined = undefined

TFormValidator extends Validator<TParentData, unknown> | undefined = undefined

TData extends DeepValue<TParentData, TName> = DeepValue<TParentData, TName>

Properties

onBlur?

ts
optional onBlur: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;
optional onBlur: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;

Defined in: packages/form-core/src/FieldApi.ts:182

An optional function, that runs on the blur event of input. If validatorAdapter is passed, this may also accept a property from the respective adapter

Example

ts
z.string().min(1) // if `zodAdapter` is passed
z.string().min(1) // if `zodAdapter` is passed

onBlurAsync?

ts
optional onBlurAsync: FieldAsyncValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;
optional onBlurAsync: FieldAsyncValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;

Defined in: packages/form-core/src/FieldApi.ts:195

An optional property similar to onBlur but async validation. If validatorAdapter is passed, this may also accept a property from the respective adapter

Example

ts
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // if `zodAdapter` is passed
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // if `zodAdapter` is passed

onBlurAsyncDebounceMs?

ts
optional onBlurAsyncDebounceMs: number;
optional onBlurAsyncDebounceMs: number;

Defined in: packages/form-core/src/FieldApi.ts:208

An optional number to represent how long the onBlurAsync should wait before running

If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds


onBlurListenTo?

ts
optional onBlurListenTo: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple<TParentData> ? PrefixTupleAccessor<TParentData<TParentData>, AllowedIndexes<TParentData<TParentData>, never>, []> : TParentData extends any[] ? PrefixArrayAccessor<TParentData<TParentData>, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor<TParentData<TParentData>, []> : TParentData extends string | number | bigint | boolean ? "" : never[];
optional onBlurListenTo: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple<TParentData> ? PrefixTupleAccessor<TParentData<TParentData>, AllowedIndexes<TParentData<TParentData>, never>, []> : TParentData extends any[] ? PrefixArrayAccessor<TParentData<TParentData>, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor<TParentData<TParentData>, []> : TParentData extends string | number | bigint | boolean ? "" : never[];

Defined in: packages/form-core/src/FieldApi.ts:212

An optional list of field names that should trigger this field's onBlur and onBlurAsync events when its value changes


onChange?

ts
optional onChange: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;
optional onChange: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;

Defined in: packages/form-core/src/FieldApi.ts:146

An optional property that takes a ValidateFn which is a generic of TData and TParentData. If validatorAdapter is passed, this may also accept a property from the respective adapter

Example

ts
z.string().min(1) // if `zodAdapter` is passed
z.string().min(1) // if `zodAdapter` is passed

onChangeAsync?

ts
optional onChangeAsync: FieldAsyncValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;
optional onChangeAsync: FieldAsyncValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;

Defined in: packages/form-core/src/FieldApi.ts:159

An optional property similar to onChange but async validation. If validatorAdapter is passed, this may also accept a property from the respective adapter

Example

ts
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // if `zodAdapter` is passed
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // if `zodAdapter` is passed

onChangeAsyncDebounceMs?

ts
optional onChangeAsyncDebounceMs: number;
optional onChangeAsyncDebounceMs: number;

Defined in: packages/form-core/src/FieldApi.ts:171

An optional number to represent how long the onChangeAsync should wait before running

If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds


onChangeListenTo?

ts
optional onChangeListenTo: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple<TParentData> ? PrefixTupleAccessor<TParentData<TParentData>, AllowedIndexes<TParentData<TParentData>, never>, []> : TParentData extends any[] ? PrefixArrayAccessor<TParentData<TParentData>, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor<TParentData<TParentData>, []> : TParentData extends string | number | bigint | boolean ? "" : never[];
optional onChangeListenTo: unknown extends TParentData ? string : TParentData extends readonly any[] & IsTuple<TParentData> ? PrefixTupleAccessor<TParentData<TParentData>, AllowedIndexes<TParentData<TParentData>, never>, []> : TParentData extends any[] ? PrefixArrayAccessor<TParentData<TParentData>, [any]> : TParentData extends Date ? never : TParentData extends object ? PrefixObjectAccessor<TParentData<TParentData>, []> : TParentData extends string | number | bigint | boolean ? "" : never[];

Defined in: packages/form-core/src/FieldApi.ts:175

An optional list of field names that should trigger this field's onChange and onChangeAsync events when its value changes


onMount?

ts
optional onMount: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;
optional onMount: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;

Defined in: packages/form-core/src/FieldApi.ts:133

An optional function that takes a param of formApi which is a generic type of TData and TParentData


onSubmit?

ts
optional onSubmit: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;
optional onSubmit: FieldValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;

Defined in: packages/form-core/src/FieldApi.ts:219

An optional function, that runs on the submit event of form. If validatorAdapter is passed, this may also accept a property from the respective adapter

Example

ts
z.string().min(1) // if `zodAdapter` is passed
z.string().min(1) // if `zodAdapter` is passed

onSubmitAsync?

ts
optional onSubmitAsync: FieldAsyncValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;
optional onSubmitAsync: FieldAsyncValidateOrFn<TParentData, TName, TFieldValidator, TFormValidator, TData>;

Defined in: packages/form-core/src/FieldApi.ts:232

An optional property similar to onSubmit but async validation. If validatorAdapter is passed, this may also accept a property from the respective adapter

Example

ts
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // if `zodAdapter` is passed
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' }) // if `zodAdapter` is passed
Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.