ZF2-569: Validate error with ,0 in I18n\Float

Description

The float validator works as expected with numbers endind with ,x where x>0, but with ,0 (or ,00 ,000 so on) it fails. With the following diff on FloatTest.php the test fails: 83c83

< $this->assertEquals(true, $this->validator->isValid('10,5'));

    $this->assertEquals(true, $this->validator->isValid('10,0'));

That's because the following line 113 in Zend\I18n\Validator\Float.php returns 10 and not 10.0 $parsedFloat = $format->parse($value, NumberFormatter::TYPE_DOUBLE);

So the comparison in the line 128 if (strval($parsedFloat) !== $valueFiltered) {

fails because 10 !== 10.0

Comments

This is very annoying. Experienced it myself. Wrote a Unit-Test, but have no idea which would be the best way to fix it. Hoping for some feedback on github.

https://github.com/zendframework/zf2/pull/2386

I added the following code in Zend\I18n\Validator\Float.php and now all tests works as expected, including 125a126,130

    while (strpos($valueFiltered,'.') !== false && ($valueFiltered[strlen($valueFiltered)-1] == '0' || $valueFiltered[strlen($valueFiltered)-1] == '.'))
    {
        $valueFiltered = substr($valueFiltered, 0, strlen($valueFiltered)-1);
    }

I made a pull request with this proposed fix: https://github.com/zendframework/zf2/pull/2388

Fixed and already merged into master and develop: https://github.com/zendframework/zf2/pull/2388