Skip to content

Commit 370edf6

Browse files
committed
Validator::validateInteger() returns false when integer is too big
1 parent 986c8dd commit 370edf6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Forms/Validator.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,11 @@ public static function validateNumeric(IControl $control): bool
290290
*/
291291
public static function validateInteger(IControl $control): bool
292292
{
293-
if (Validators::isNumericInt($value = $control->getValue())) {
294-
if (!is_float($tmp = $value * 1)) { // bigint leave as string
295-
$control->setValue($tmp);
296-
}
293+
if (
294+
Validators::isNumericInt($value = $control->getValue())
295+
&& !is_float($tmp = $value * 1) // too big for int?
296+
) {
297+
$control->setValue($tmp);
297298
return true;
298299
}
299300
return false;

tests/Forms/Controls.TestBase.validators.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test(function () {
196196
Assert::same('123.5', $control->value);
197197

198198
$control->value = PHP_INT_MAX . PHP_INT_MAX;
199-
Assert::true(Validator::validateInteger($control));
199+
Assert::false(Validator::validateInteger($control));
200200
Assert::same(PHP_INT_MAX . PHP_INT_MAX, $control->value);
201201
});
202202

0 commit comments

Comments
 (0)