Skip to content

Commit

Permalink
fix(useAsyncValidator): fix Schema importing from async-validator (#2761
Browse files Browse the repository at this point in the history
)

Co-authored-by: Jelf <353742991@qq.com>
  • Loading branch information
theruziev and okxiaoliang4 committed Feb 16, 2023
1 parent ad3d042 commit dbcdbfb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/integrations/useAsyncValidator/index.ts
Expand Up @@ -5,6 +5,9 @@ import type { Rules, ValidateError, ValidateOption } from 'async-validator'
import type { Ref } from 'vue-demi'
import { computed, ref, watchEffect } from 'vue-demi'

// @ts-expect-error Schema.default is exist in ssr mode
const AsyncValidatorSchema = Schema || Schema.default

export type AsyncValidatorError = Error & {
errors: ValidateError[]
fields: Record<string, ValidateError[]>
Expand Down Expand Up @@ -47,7 +50,7 @@ export function useAsyncValidator(
watchEffect(async () => {
isFinished.value = false
pass.value = false
const validator = new Schema(resolveUnref(rules))
const validator = new AsyncValidatorSchema(resolveUnref(rules))
try {
await validator.validate(resolveUnref(value), validateOption)
pass.value = true
Expand Down

0 comments on commit dbcdbfb

Please sign in to comment.