mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-06 17:18:40 +08:00
parent
8c0e978314
commit
db32ef9621
@ -149,7 +149,7 @@ const validator = (val: any) => {
|
||||
if (String(val).length >= 4) {
|
||||
return Promise.resolve()
|
||||
} else {
|
||||
return Promise.reject('长度不得小于4')
|
||||
return Promise.reject(new Error('长度不得小于4'))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ async function validate(prop?: string): Promise<{ valid: boolean; errors: ErrorM
|
||||
if (isPromise(result)) {
|
||||
promises.push(
|
||||
result
|
||||
.then((res: any) => {
|
||||
.then((res) => {
|
||||
if (typeof res === 'string') {
|
||||
errors.push({
|
||||
prop,
|
||||
@ -94,10 +94,11 @@ async function validate(prop?: string): Promise<{ valid: boolean; errors: ErrorM
|
||||
valid = false
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: string | Error) => {
|
||||
const message = typeof error === 'string' ? error : error.message
|
||||
errors.push({
|
||||
prop,
|
||||
message: error || rule.message
|
||||
message: message || rule.message
|
||||
})
|
||||
valid = false
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user