valitron icon indicating copy to clipboard operation
valitron copied to clipboard

integer validation fails for large numbers

Open hirani89 opened this issue 5 years ago • 4 comments

I tried to validate &action=get&id=555555555555 and it fails. But &action=get&id=555 works fine. I keep getting Id must be an integer

hirani89 avatar Dec 05 '19 01:12 hirani89

That's strange :) Can you share a bit more of your code?

willemwollebrants avatar Dec 08 '19 11:12 willemwollebrants

I know this is happening. It's because of php int range. Which is -2,147,483,647 - 2,147,483,647. So if I entered 2,147,483,648, it would fail.

hirani89 avatar Dec 08 '19 11:12 hirani89

The problem is that I tested this, and it validates:

$v = new \Valitron\Validator([
    'num_1'=>'555555555555',
    'num_2'=>'2147483648'
]);

$v->rule('integer', ['num_1', 'num_2']);
var_dump($v->validate()); //returns true 

willemwollebrants avatar Dec 08 '19 11:12 willemwollebrants

Hi,

I get false for the same test. Do you think this might be an issue with the php version of the platform php is on? I am running php 5.6.17 on IIS.

hirani89 avatar Dec 10 '19 00:12 hirani89