Commit 5eef48b9 authored by sunlei33's avatar sunlei33 Committed by baiyaaaaa

Form: 如果需要验证的fields为空,调用验证时立刻返回callback (#3944)

* Form: 如果需要验证的fields为空,调用验证时立刻返回callback
同时修复几个代码格式用来通过npm run dist

* fix travis

* fix travis

* fix travis
parent 81ba7084
...@@ -59,6 +59,10 @@ ...@@ -59,6 +59,10 @@
validate(callback) { validate(callback) {
let valid = true; let valid = true;
let count = 0; let count = 0;
// 如果需要验证的fields为空,调用验证时立刻返回callback
if (this.fields.length === 0 && callback) {
callback(true);
}
this.fields.forEach((field, index) => { this.fields.forEach((field, index) => {
field.validate('', errors => { field.validate('', errors => {
if (errors) { if (errors) {
......
...@@ -158,4 +158,5 @@ ...@@ -158,4 +158,5 @@
} }
} }
}; };
</script> </script>
\ No newline at end of file
...@@ -172,4 +172,5 @@ ...@@ -172,4 +172,5 @@
); );
} }
}; };
</script> </script>
\ No newline at end of file
...@@ -27,4 +27,5 @@ ...@@ -27,4 +27,5 @@
} }
} }
}; };
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment