import { MaybeRefOrGetter } from '@vueuse/shared'; import { ValidateError, ValidateOption, Rules } from 'async-validator'; import { Ref } from 'vue-demi'; type AsyncValidatorError = Error & { errors: ValidateError[]; fields: Record; }; interface UseAsyncValidatorExecuteReturn { pass: boolean; errors: AsyncValidatorError['errors'] | undefined; errorInfo: AsyncValidatorError | null; errorFields: AsyncValidatorError['fields'] | undefined; } interface UseAsyncValidatorReturn { pass: Ref; isFinished: Ref; errors: Ref; errorInfo: Ref; errorFields: Ref; execute: () => Promise; } 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 */ declare function useAsyncValidator(value: MaybeRefOrGetter>, rules: MaybeRefOrGetter, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike; export { type AsyncValidatorError, type UseAsyncValidatorExecuteReturn, type UseAsyncValidatorOptions, type UseAsyncValidatorReturn, useAsyncValidator };