Skip to content

Commit

Permalink
Closes swoft-cloud/swoft/issues#1274
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonYH committed May 13, 2020
1 parent f563df5 commit 5db6b2f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/validator/src/Rule/IsBoolRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public function validate(array $data, string $propertyName, $item, $default = nu
throw new ValidatorException($message);
}

$value = $data[$propertyName];
if ($value == 'true' || $value == 'false' || is_bool($value)) {
$data[$propertyName] = (bool)$value;
$value = filter_var($data[$propertyName], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);

if (is_bool($value)) {
$data[$propertyName] = $value;
return $data;
}

Expand Down

0 comments on commit 5db6b2f

Please sign in to comment.