MVC - IntegerFieldType: fix IntegerValidator returning false for negative numbers (#5837)

This commit is contained in:
Nicola 2022-07-03 19:31:59 +02:00 committed by GitHub
parent 6a69e524e0
commit 5cffdd7ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,7 @@ class IntegerValidator extends BaseValidator
{
$value = $validator->getValue($attribute);
$msg = $this->getOption('message');
if (ctype_digit(strval(($value))) == false or (string)((int)$value) !== (string)$value) {
if (filter_var($value, FILTER_VALIDATE_INT) === false) {
$validator->appendMessage(new Message($msg, $attribute, 'IntegerValidator'));
return false;
}