deps(form): update async-validator (#842)

This commit is contained in:
Yugang Cao 2021-08-11 23:41:08 +08:00 committed by GitHub
parent 6341f54971
commit b44901e111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 12 deletions

View File

@ -119,7 +119,7 @@
"@css-render/vue3-ssr": "^0.15.4",
"@types/lodash": "^4.14.170",
"@types/lodash-es": "^4.17.4",
"async-validator": "^3.5.1",
"async-validator": "^4.0.1",
"css-render": "^0.15.4",
"date-fns": "^2.19.0",
"evtd": "^0.2.2",

View File

@ -1,5 +1,5 @@
import { h, defineComponent, PropType, provide, ExtractPropTypes } from 'vue'
import { ErrorList } from 'async-validator'
import { ValidateError } from 'async-validator'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { formLight } from '../styles'
@ -84,7 +84,7 @@ export default defineComponent({
.filter((result) => result.errors)
.map((result) => result.errors)
if (validateCallback) {
validateCallback(errors as ErrorList[])
validateCallback(errors as ValidateError[][])
} else {
reject(errors)
}

View File

@ -13,7 +13,11 @@ import {
Transition,
renderSlot
} from 'vue'
import Schema, { ErrorList, RuleItem, ValidateOption } from 'async-validator'
import Schema, {
ValidateError,
RuleItem,
ValidateOption
} from 'async-validator'
import { get } from 'lodash-es'
import { createId } from 'seemly'
import { formItemInjectionKey } from '../../_mixins/use-form-item'
@ -199,7 +203,7 @@ export default defineComponent({
void internalValidate('input')
}
// Resolve : ()
// Reject : (errors: AsyncValidator.ErrorList)
// Reject : (errors: AsyncValidator.ValidateError[])
async function validate (options: FormItemValidateOptions): Promise<void>
async function validate (
trigger?: string | null,
@ -252,7 +256,7 @@ export default defineComponent({
}
): Promise<{
valid: boolean
errors?: ErrorList
errors?: ValidateError[]
}> => {
const { path } = props
if (!options) {
@ -305,7 +309,9 @@ export default defineComponent({
options,
(errors, fields) => {
if (errors?.length) {
explainsRef.value = errors.map((error) => error.message)
explainsRef.value = errors.map(
(error: ValidateError) => error?.message ?? ''
)
validationErroredRef.value = true
resolve({
valid: false,

View File

@ -1,5 +1,5 @@
import { InjectionKey } from 'vue'
import { ErrorList, RuleItem, ValidateOption } from 'async-validator'
import { ValidateError, RuleItem, ValidateOption } from 'async-validator'
import { FormSetupProps } from './Form'
export interface FormRules {
@ -38,7 +38,7 @@ export type FormItemInternalValidate = (
options?: ValidateOption
) => Promise<{
valid: boolean
errors?: ErrorList
errors?: ValidateError[]
}>
export type FormItemValidate = ((
@ -69,13 +69,13 @@ export type Size = 'small' | 'medium' | 'large'
export type ValidationTrigger = 'input' | 'change' | 'blur' | 'focus'
export type ApplyRule = (rule: FormItemRule) => boolean
export type ValidateCallback = (errors?: ErrorList) => void
export type ValidateCallback = (errors?: ValidateError[]) => void
export type FormValidateCallback = (errors?: ErrorList[]) => void
export type FormValidateCallback = (errors?: ValidateError[][]) => void
export type FormValidate = ((callback?: FormValidateCallback) => void) &
(() => Promise<void>)
export type FormValidationError = ErrorList
export type FormValidationError = ValidateError[]
export interface FormInst {
validate: FormValidate