zendframework/zend-validator

Bug with the Step validator

Closed this issue · 2 comments

Step validator is not working properly. For example if I set baseValue = 50 and step = 0.01 then the validation fails for the value of 50.09, which is perfectly valid. I think the problem is in the calculation of the fmod:

$fmod = $this->fmod($value - $this->baseValue, $this->step);

In this example $value - $this->baseValue == 0.090000000000003 and then $fmod == 3.41E-15. Maybe it the fmod is rounded to the precision of the step the issue will be fixed.

I'm using PHP 5.6.33

Requires a test case

Hi @Ocramius and @froschdesign,

I added some unit tests to prove the bug pull request
You can see the travis build