Skip to content

Commit f481bdb

Browse files
eceltovkrulis-martin
authored andcommitted
VBool text validation now supports strings as well
1 parent c164fe0 commit f481bdb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/helpers/MetaFormats/Validators/VBool.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ public function getExampleValue(): string
1616

1717
public function validateText(mixed $value): bool
1818
{
19-
// additionally allow 0 and 1
20-
return $value === 0 || $value === 1 || $this->validateJson($value);
19+
// FILTER_VALIDATE_BOOL is not used because it additionally allows "on", "yes", "off", "no" and ""
20+
21+
// urlencoded params are strings
22+
return $value === "0"
23+
|| $value === "1"
24+
|| $value === "true"
25+
|| $value === "false"
26+
|| $value === 0
27+
|| $value === 1
28+
|| $this->validateJson($value);
2129
}
2230

2331
public function validateJson(mixed $value): bool

0 commit comments

Comments
 (0)