From d120355bc2d04a2294ae98666bc9b773e53d1c5d Mon Sep 17 00:00:00 2001 From: Erik Bohony Date: Mon, 16 Oct 2023 12:21:45 +0200 Subject: [PATCH] fix required field --- src/Params/ParamsProcessor.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Params/ParamsProcessor.php b/src/Params/ParamsProcessor.php index b055064..6582800 100644 --- a/src/Params/ParamsProcessor.php +++ b/src/Params/ParamsProcessor.php @@ -22,9 +22,11 @@ public function __construct(array $params) public function isError(): bool { foreach ($this->params as $param) { - $validationResult = $param->validate(); - if (!$validationResult->isOk()) { - $this->errors[$param->getKey()] = $validationResult->getErrors(); + if($param->isRequired() || !empty($param->getValue())){ + $validationResult = $param->validate(); + if (!$validationResult->isOk()) { + $this->errors[$param->getKey()] = $validationResult->getErrors(); + } } } return !empty($this->errors);