From 6de8d6b2f4b31454d18563c1c6661c3641b0e23d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 7 Oct 2021 16:02:17 +0200 Subject: [PATCH] BaseFormElement: Don't evaluate validators by hand refs #28 --- src/FormElement/BaseFormElement.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/FormElement/BaseFormElement.php b/src/FormElement/BaseFormElement.php index 0770b5dc..e9c78761 100644 --- a/src/FormElement/BaseFormElement.php +++ b/src/FormElement/BaseFormElement.php @@ -251,17 +251,8 @@ public function setValue($value) */ public function validate() { - $valid = true; - - foreach ($this->getValidators() as $validator) { - if (! $validator->isValid($this->getValue())) { - $valid = false; - - $this->addMessages($validator->getMessages()); - } - } - - $this->valid = $valid; + $this->valid = $this->getValidators()->isValid($this->getValue()); + $this->addMessages($this->getValidators()->getMessages()); return $this; }