feat(Form): add validateField method

This commit is contained in:
陈嘉涵
2020-02-13 15:10:50 +08:00
parent 4059643f2f
commit b4d117f59d
4 changed files with 24 additions and 3 deletions

View File

@@ -67,6 +67,25 @@ export default createComponent({
return this.validateFirst ? this.validateSeq() : this.validateAll();
},
// @exposed-api
validateField(name) {
const matched = this.fields.filter(item => item.name === name);
if (matched.length) {
return new Promise((resolve, reject) => {
matched[0].validate().then(error => {
if (error) {
reject(error);
} else {
resolve();
}
});
});
}
return Promise.reject();
},
// @exposed-api
resetValidation() {
this.fields.forEach(item => {