Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useAsyncValidator): fix Schema importing from async-validator #2761

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/integrations/useAsyncValidator/index.ts
Original file line number Diff line number Diff line change
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