Skip to content

Commit

Permalink
made VBool stricter
Browse files Browse the repository at this point in the history
  • Loading branch information
eceltov committed Feb 28, 2025
1 parent 14b11df commit c0335c5
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions app/helpers/MetaFormats/Validators/VBool.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@
use App\Helpers\MetaFormats\PhpTypes;

/**
* Validates boolean values. Accepts bools, "true", "false", 0 and 1.
* Validates boolean values. Accepts only boolean true and false.
*/
class VBool
{
public const SWAGGER_TYPE = "boolean";

public function validate(mixed $value)
{
// support stringified values as well as 0 and 1
return MetaFormatHelper::checkType($value, PhpTypes::Bool)
|| $value == 0
|| $value == 1
|| $value == "true"
|| $value == "false";
return $value === true || $value === false;
}
}

0 comments on commit c0335c5

Please sign in to comment.