Form: validate method reject error info (#21374)

This commit is contained in:
好多大米 2021-10-11 15:15:51 +08:00 committed by GitHub
parent 492ab00ad7
commit 6ae261d840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -116,8 +116,8 @@
// if no callback, return promise
if (typeof callback !== 'function' && window.Promise) {
promise = new window.Promise((resolve, reject) => {
callback = function(valid) {
valid ? resolve(valid) : reject(valid);
callback = function(valid, invalidFields) {
valid ? resolve(valid) : reject(invalidFields);
};
});
}

View File

@ -921,8 +921,8 @@ describe('Form', () => {
};
}
}, true);
vm.$refs.form.validate().catch(validFailed => {
expect(validFailed).to.false;
vm.$refs.form.validate().catch(invalidFields => {
expect(invalidFields.name[0].message).to.be.equal('长度至少为5');
done();
});
});