Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useAsyncValidator.md
1---2category: '@Integrations'3---45# useAsyncValidator67Wrapper for [`async-validator`](https://github.com/yiminghe/async-validator).89## Install1011```bash12npm i async-validator@^413```1415## Usage1617```ts18import { useAsyncValidator } from '@vueuse/integrations/useAsyncValidator'19```2021## Type Declarations2223```ts24export type AsyncValidatorError = Error & {25errors: ValidateError[]26fields: Record<string, ValidateError[]>27}28export interface UseAsyncValidatorExecuteReturn {29pass: boolean30errors: AsyncValidatorError["errors"] | undefined31errorInfo: AsyncValidatorError | null32errorFields: AsyncValidatorError["fields"] | undefined33}34export interface UseAsyncValidatorReturn {35pass: ShallowRef<boolean>36isFinished: ShallowRef<boolean>37errors: ComputedRef<AsyncValidatorError["errors"] | undefined>38errorInfo: ShallowRef<AsyncValidatorError | null>39errorFields: ComputedRef<AsyncValidatorError["fields"] | undefined>40execute: () => Promise<UseAsyncValidatorExecuteReturn>41}42export interface UseAsyncValidatorOptions {43/**44* @see https://github.com/yiminghe/async-validator#options45*/46validateOption?: ValidateOption47/**48* The validation will be triggered right away for the first time.49* Only works when `manual` is not set to true.50*51* @default true52*/53immediate?: boolean54/**55* If set to true, the validation will not be triggered automatically.56*/57manual?: boolean58}59/**60* Wrapper for async-validator.61*62* @see https://vueuse.org/useAsyncValidator63* @see https://github.com/yiminghe/async-validator64*/65export declare function useAsyncValidator(66value: MaybeRefOrGetter<Record<string, any>>,67rules: MaybeRefOrGetter<Rules>,68options?: UseAsyncValidatorOptions,69): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>70```71