FieldValidators

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

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>;

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

Defined in

packages/form-core/src/FieldApi.ts:199


onBlurAsync?

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

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

Defined in

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


onBlurAsyncDebounceMs?

ts
optional onBlurAsyncDebounceMs: number;
optional onBlurAsyncDebounceMs: number;

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

Defined in

packages/form-core/src/FieldApi.ts:225


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[];

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

Defined in

packages/form-core/src/FieldApi.ts:229


onChange?

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

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

Defined in

packages/form-core/src/FieldApi.ts:163


onChangeAsync?

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

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

Defined in

packages/form-core/src/FieldApi.ts:176


onChangeAsyncDebounceMs?

ts
optional onChangeAsyncDebounceMs: number;
optional onChangeAsyncDebounceMs: number;

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

Defined in

packages/form-core/src/FieldApi.ts:188


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[];

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

Defined in

packages/form-core/src/FieldApi.ts:192


onMount?

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

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

Defined in

packages/form-core/src/FieldApi.ts:150


onSubmit?

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

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

Defined in

packages/form-core/src/FieldApi.ts:236


onSubmitAsync?

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

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

Defined in

packages/form-core/src/FieldApi.ts:249

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.