mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +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>
|
<script lang="ts" setup>
|
||||||
import wdToast from '../wd-toast/wd-toast.vue'
|
import wdToast from '../wd-toast/wd-toast.vue'
|
||||||
import { reactive, watch } from '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 { useChildren } from '../composables/useChildren'
|
||||||
import { useToast } from '../wd-toast'
|
import { useToast } from '../wd-toast'
|
||||||
import { type FormRules, FORM_KEY, type ErrorMessage, formProps, type FormExpose } from './types'
|
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
|
valid = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error: string | Error) => {
|
.catch((error?: string | Error) => {
|
||||||
const message = typeof error === 'string' ? error : error.message
|
const message = isDef(error) ? (isString(error) ? error : error.message || rule.message) : rule.message
|
||||||
errors.push({
|
errors.push({ prop, message })
|
||||||
prop,
|
|
||||||
message: message || rule.message
|
|
||||||
})
|
|
||||||
valid = false
|
valid = false
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user