From 0e6a1b5ba21549e9892882b01d6bca67de4f5a87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 2 Dec 2021 16:33:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Validator.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Validator.php b/src/Validator.php index 01be564..a25aaa7 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -186,13 +186,14 @@ class Validator extends BaseValidator return true; } foreach ($this->validators as $val) { - if ($this->check($val)) { + [$result, $validator] = $this->check($val); + if ($result === true) { continue; } $isTrue = false; - if ($val instanceof BaseValidator) { - var_dump($val->getError()); - $this->addError($val->getError()); + if ($validator instanceof BaseValidator) { + var_dump($validator->getError()); + $this->addError($validator->getError()); } break; } @@ -209,7 +210,7 @@ class Validator extends BaseValidator private function check(BaseValidator|array|Closure $val): mixed { if (is_callable($val, true)) { - return call_user_func($val, $this); + return [call_user_func($val, $this), $val]; } $class = Kiri::getDi()->get($val['class']); @@ -217,7 +218,7 @@ class Validator extends BaseValidator Kiri::configure($class, $val); - return $class->trigger(); + return [$class->trigger(), $class]; } }