fix: async validator (#3194)

This commit is contained in:
bowen 2023-10-26 11:54:09 +08:00 committed by GitHub
parent 4755017bcc
commit 405ef9e2b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -192,10 +192,12 @@
message: '请输入数据', message: '请输入数据',
}, },
{ {
trigger: 'blur',
validator(_, value) { validator(_, value) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!value) return resolve();
isAccountExist(value) isAccountExist(value)
.then(() => resolve()) .then(resolve)
.catch((err) => { .catch((err) => {
reject(err.message || '验证失败'); reject(err.message || '验证失败');
}); });

View File

@ -89,10 +89,12 @@ export const accountFormSchema: FormSchema[] = [
message: '请输入用户名', message: '请输入用户名',
}, },
{ {
trigger: 'blur',
validator(_, value) { validator(_, value) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!value) return resolve();
isAccountExist(value) isAccountExist(value)
.then(() => resolve()) .then(resolve)
.catch((err) => { .catch((err) => {
reject(err.message || '验证失败'); reject(err.message || '验证失败');
}); });