Skip to content

useAsyncValidator

Category
Export Size
1.13 kB
Package
@vueuse/integrations
Last Changed
7 months ago

Wrapper for async-validator.

Demo

pass:false
isFinished:true

Email
email is required
Name
name is required
Age
age is required
Available in the @vueuse/integrations add-on.

Install

bash
npm i async-validator@^4

Usage

ts
import { 
useAsyncValidator
} from '@vueuse/integrations/useAsyncValidator'
js
export {}

Type Declarations

Show Type Declarations
ts
export type 
AsyncValidatorError
= Error & {
errors
:
ValidateError
[]
fields
:
Record
<string,
ValidateError
[]>
} export interface UseAsyncValidatorExecuteReturn {
pass
: boolean
errors
:
AsyncValidatorError
["errors"] | undefined
errorInfo
:
AsyncValidatorError
| null
errorFields
:
AsyncValidatorError
["fields"] | undefined
} export interface UseAsyncValidatorReturn {
pass
:
ShallowRef
<boolean>
isFinished
:
ShallowRef
<boolean>
errors
:
ComputedRef
<
AsyncValidatorError
["errors"] | undefined>
errorInfo
:
ShallowRef
<
AsyncValidatorError
| null>
errorFields
:
ComputedRef
<
AsyncValidatorError
["fields"] | undefined>
execute
: () =>
Promise
<UseAsyncValidatorExecuteReturn>
} export interface UseAsyncValidatorOptions { /** * @see https://github.com/yiminghe/async-validator#options */
validateOption
?:
ValidateOption
/** * The validation will be triggered right away for the first time. * Only works when `manual` is not set to true. * * @default true */
immediate
?: boolean
/** * If set to true, the validation will not be triggered automatically. */
manual
?: boolean
} /** * Wrapper for async-validator. * * @see https://vueuse.org/useAsyncValidator * @see https://github.com/yiminghe/async-validator */ export declare function
useAsyncValidator
(
value
:
MaybeRefOrGetter
<
Record
<string, any>>,
rules
:
MaybeRefOrGetter
<
Rules
>,
options
?: UseAsyncValidatorOptions,
): UseAsyncValidatorReturn &
PromiseLike
<UseAsyncValidatorReturn>

Source

SourceDemoDocs

Contributors

Anthony Fu
Anthony Fu
IlyaL
IlyaL
Jaw
Jelf
Vida Xie
Robin
James Garbutt
Doctorwu
류한경
Bakhtiyor Ruziev
Bakhtiyor Ruziev
Hawtim
vaakian X
Curt Grimes

Changelog

v14.0.0-alpha.2 on
d5bcd - fix(integrations): use relative import in component.ts (#5025)
v14.0.0-alpha.0 on
8c521 - feat(components)!: refactor components and make them consistent (#4912)
v12.8.0 on
7432f - feat(types): deprecate MaybeRef and MaybeRefOrGetter in favor of Vue's native (#4636)
v12.3.0 on
59f75 - feat(toValue): deprecate toValue from @vueuse/shared in favor of Vue's native
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)

Released under the MIT License.

Turn AI into a coding partner
Claim 40% off for AIDD Masterclass.
Get discount