From 01481c58457635861e25bdbd4cc7d1daf22967a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 03:38:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Validator/BindForm.php | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Validator/BindForm.php diff --git a/src/Validator/BindForm.php b/src/Validator/BindForm.php new file mode 100644 index 0000000..0183192 --- /dev/null +++ b/src/Validator/BindForm.php @@ -0,0 +1,41 @@ +getReflectionClass($this->formValidate); + $model = $reflect->newInstanceWithoutConstructor(); + foreach ($reflect->getProperties() as $property) { + foreach ($property->getAttributes() as $attribute) { + $rule = $attribute->newInstance(); + if ($rule instanceof ValidatorInterface) { + $validator->addRule($property->getName(), $model, $rule); + } + } + } + return $validator; + } + +}