Make requirement validation more readable in UserFormField::validate()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 25 Aug 2021 11:25:31 +0000 (13:25 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 25 Aug 2021 11:25:31 +0000 (13:25 +0200)
wcfsetup/install/files/lib/system/form/builder/field/user/UserFormField.class.php

index 4b365da45f9290b173a70fb6c43ef6ef2d576efe..6a6be22c9fa63adcb13bf0e732f28426fd540ce4 100644 (file)
@@ -137,13 +137,14 @@ class UserFormField extends AbstractFormField implements
      */
     public function validate()
     {
-        if (
-            $this->isRequired() && (
-                ($this->getValue() === null || $this->getValue() === '')
+        if ($this->isRequired()) {
+            if (
+                $this->getValue() === null
+                || $this->getValue() === ''
                 || (\is_array($this->getValue()) && empty($this->getValue()))
-            )
-        ) {
-            $this->addValidationError(new FormFieldValidationError('empty'));
+            ) {
+                $this->addValidationError(new FormFieldValidationError('empty'));
+            }
         }
 
         if ($this->allowsMultiple()) {