Skip to content

API reference > @kontsedal/olas-core > debouncedValidator

debouncedValidator() function ​

Wrap an async validator with a debounce. The debounce timer resets on every value change. While debouncing or the request is in flight, the field'sisValidating is true and isValid HOLDS its last settled value (T5.3) — so editing an already-valid field doesn't strobe a submit button to disabled on every keystroke. A field with no prior settled validation defaults to valid.

A fn that throws synchronously, or returns no promise, fails the pass the way a sync validator that throws does: the message shows on the field and the error reaches onError. The pass settles either way.

Signature:

typescript
export declare function debouncedValidator<T>(fn: (value: T, signal: AbortSignal) => Promise<string | null>, ms: number): (value: T, signal: AbortSignal) => Promise<string | null>;

Parameters ​

Parameter

Type

Description

fn

(value: T, signal: AbortSignal) => Promise<string | null>

ms

number

Returns:

(value: T, signal: AbortSignal) => Promise<string | null>

Released under the MIT License.