Skip to content
On this page

useAsyncValidator

Category
Package
@vueuse/integrations
Last Changed
last month

wrapper for async-validator

Demo

pass: false
isFinished: false
email:
name:
age:
available in add-on @vueuse/integrations

Install

npm i async-validator
npm i async-validator

Usage

import { useAsyncValidator } from '@vueuse/integrations/useAsyncValidator'
import { useAsyncValidator } from '@vueuse/integrations/useAsyncValidator'

Type Declarations

export declare type AsyncValidatorError = Error & {
  errors: ValidateError[]
  fields: Record<string, ValidateError[]>
}
export interface UseAsyncValidatorReturn {
  pass: Ref<boolean>
  errorInfo: Ref<AsyncValidatorError | null>
  isFinished: Ref<boolean>
  errors: Ref<AsyncValidatorError["errors"] | undefined>
  errorFields: Ref<AsyncValidatorError["fields"] | undefined>
}
export interface UseAsyncValidatorOptions {
  /**
   * @see https://github.com/yiminghe/async-validator#options
   */
  validateOption?: ValidateOption
}
/**
 * Wrapper for async-validator.
 *
 * @see https://vueuse.org/useAsyncValidator
 * @see https://github.com/yiminghe/async-validator
 */
export declare function useAsyncValidator(
  value: MaybeRef<Record<string, any>>,
  rules: MaybeRef<Rules>,
  options?: UseAsyncValidatorOptions
): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>
export declare type AsyncValidatorError = Error & {
  errors: ValidateError[]
  fields: Record<string, ValidateError[]>
}
export interface UseAsyncValidatorReturn {
  pass: Ref<boolean>
  errorInfo: Ref<AsyncValidatorError | null>
  isFinished: Ref<boolean>
  errors: Ref<AsyncValidatorError["errors"] | undefined>
  errorFields: Ref<AsyncValidatorError["fields"] | undefined>
}
export interface UseAsyncValidatorOptions {
  /**
   * @see https://github.com/yiminghe/async-validator#options
   */
  validateOption?: ValidateOption
}
/**
 * Wrapper for async-validator.
 *
 * @see https://vueuse.org/useAsyncValidator
 * @see https://github.com/yiminghe/async-validator
 */
export declare function useAsyncValidator(
  value: MaybeRef<Record<string, any>>,
  rules: MaybeRef<Rules>,
  options?: UseAsyncValidatorOptions
): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>

Source

SourceDemoDocs

Contributors

Jelf
Anthony Fu

Changelog

v8.7.4 on 6/18/2022
5c742 - feat: new options (#1695)
v8.6.0 on 5/31/2022
f4226 - feat: new function (#1497)
useAsyncValidator has loaded