Skip to content

Commit

Permalink
Form: validate method reject error info
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 committed Oct 9, 2021
1 parent 492ab00 commit b696c7e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/form/src/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down

0 comments on commit b696c7e

Please sign in to comment.