mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 09:08:51 +08:00
fix: 🐛 修复 Form 表单 validator 校验不通过且未指定错误信息时无法显示校验信息的问题 (#791)
This commit is contained in:
parent
44df081dbd
commit
bdb56537db
@ -19,7 +19,7 @@ export default {
|
||||
<script lang="ts" setup>
|
||||
import wdToast from '../wd-toast/wd-toast.vue'
|
||||
import { reactive, watch } from 'vue'
|
||||
import { deepClone, getPropByPath, isDef, isPromise } from '../common/util'
|
||||
import { deepClone, getPropByPath, isDef, isPromise, isString } from '../common/util'
|
||||
import { useChildren } from '../composables/useChildren'
|
||||
import { useToast } from '../wd-toast'
|
||||
import { type FormRules, FORM_KEY, type ErrorMessage, formProps, type FormExpose } from './types'
|
||||
@ -94,12 +94,9 @@ async function validate(prop?: string): Promise<{ valid: boolean; errors: ErrorM
|
||||
valid = false
|
||||
}
|
||||
})
|
||||
.catch((error: string | Error) => {
|
||||
const message = typeof error === 'string' ? error : error.message
|
||||
errors.push({
|
||||
prop,
|
||||
message: message || rule.message
|
||||
})
|
||||
.catch((error?: string | Error) => {
|
||||
const message = isDef(error) ? (isString(error) ? error : error.message || rule.message) : rule.message
|
||||
errors.push({ prop, message })
|
||||
valid = false
|
||||
})
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user