From 143b3c769fd341710ad2a3e4c19945bb5ec997f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 25 Aug 2021 13:25:31 +0200 Subject: [PATCH] Make requirement validation more readable in UserFormField::validate() --- .../form/builder/field/user/UserFormField.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/user/UserFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/user/UserFormField.class.php index 4b365da45f..6a6be22c9f 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/user/UserFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/user/UserFormField.class.php @@ -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()) { -- 2.20.1