FieldValidators

Interface: FieldValidators<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync>

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

Type Parameters

TParentData

TName extends DeepKeys<TParentData>

TData extends DeepValue<TParentData, TName>

TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>

TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>

TOnChangeAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>

TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>

TOnBlurAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>

TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>

TOnSubmitAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>

Properties

onBlur?

ts
optional onBlur: TOnBlur;
optional onBlur: TOnBlur;

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

An optional function, that runs on the blur event of input.

Example

ts
z.string().min(1)
z.string().min(1)

onBlurAsync?

ts
optional onBlurAsync: TOnBlurAsync;
optional onBlurAsync: TOnBlurAsync;

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

An optional property similar to onBlur but async validation.

Example

ts
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })

onBlurAsyncDebounceMs?

ts
optional onBlurAsyncDebounceMs: number;
optional onBlurAsyncDebounceMs: number;

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

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: DeepKeys<TParentData>[];
optional onBlurListenTo: DeepKeys<TParentData>[];

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

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


onChange?

ts
optional onChange: TOnChange;
optional onChange: TOnChange;

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

An optional function, that runs on the change event of input.

Example

ts
z.string().min(1)
z.string().min(1)

onChangeAsync?

ts
optional onChangeAsync: TOnChangeAsync;
optional onChangeAsync: TOnChangeAsync;

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

An optional property similar to onChange but async validation

Example

ts
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })

onChangeAsyncDebounceMs?

ts
optional onChangeAsyncDebounceMs: number;
optional onChangeAsyncDebounceMs: number;

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

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: DeepKeys<TParentData>[];
optional onChangeListenTo: DeepKeys<TParentData>[];

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

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


onMount?

ts
optional onMount: TOnMount;
optional onMount: TOnMount;

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

An optional function, that runs on the mount event of input.


onSubmit?

ts
optional onSubmit: TOnSubmit;
optional onSubmit: TOnSubmit;

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

An optional function, that runs on the submit event of form.

Example

ts
z.string().min(1)
z.string().min(1)

onSubmitAsync?

ts
optional onSubmitAsync: TOnSubmitAsync;
optional onSubmitAsync: TOnSubmitAsync;

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

An optional property similar to onSubmit but async validation.

Example

ts
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
z.string().refine(async (val) => val.length > 3, { message: 'Testing 123' })
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.

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.