Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
riculum committed May 14, 2022
1 parent 30788bc commit 8728b8e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,14 @@ public static function isValidEnum(?string $enum, array $enums, bool $required =
}
}

#[Pure] public static function isValidBoolean($boolean): bool
public static function isValidBoolean($boolean): bool
{
return self::validateBoolean($boolean);
try {
self::validateBoolean($boolean);
return true;
} catch (InvalidValidationException $e) {
return false;
}
}

/**
Expand Down Expand Up @@ -1071,8 +1076,15 @@ public static function validateChar(?string $char, int $minLength = 1, int $maxL
return $char;
}

/**
* @throws InvalidValidationException
*/
static function validateBoolean($boolean): bool
{
return is_bool($boolean);
if (is_bool($boolean)) {
return $boolean;
} else {
throw new InvalidValidationException($boolean . ' is not a valid boolean');
}
}
}

0 comments on commit 8728b8e

Please sign in to comment.