diff --git a/src/Parameter.php b/src/Parameter.php index 4dcd079..b56e9d0 100644 --- a/src/Parameter.php +++ b/src/Parameter.php @@ -258,7 +258,7 @@ public function assertValue($value) { // required? if (empty($value)) { - if ($this->getRequired()) { + if ($this->getRequired() && !$this->isBooleanWithValueFalse($value)) { $this->throwInvalidParameter($this->getName().' is required'); } //no need to continue, the value is empty & not required @@ -361,4 +361,12 @@ protected function throwInvalidParameter($message) new Error($message, 'parameter-invalid'), ]); } + + /** + * @param mixed $value + */ + private function isBooleanWithValueFalse($value): bool + { + return $this->getType() === self::TYPE_BOOLEAN && is_bool($value) && $value === false; + } }