改写Validate类和单元测试

This commit is contained in:
thinkphp
2016-03-19 21:59:44 +08:00
parent 386e7ab8d3
commit 9512bfc29a
7 changed files with 746 additions and 294 deletions

View File

@@ -989,11 +989,12 @@ class Model
protected function dataValidate(&$data)
{
if (!empty($this->options['validate'])) {
if (!empty($this->rule)) {
Validate::rule($this->rule);
$validate = Loader::validate($this->name);
if (is_array($this->options['validate'])) {
$validate->rule($this->options['validate']);
}
if (!Validate::check($data, $this->options['validate'])) {
$this->error = Validate::getError();
if (!$validate->check($data)) {
$this->error = $validate->getError();
return false;
}
$this->options['validate'] = null;