Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Commit

Permalink
Merge 7e4af6e into 020d03b
Browse files Browse the repository at this point in the history
  • Loading branch information
jutein committed Nov 20, 2020
2 parents 020d03b + 7e4af6e commit 9891384
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 9891384

Please sign in to comment.