Skip to content

Commit

Permalink
Merge branch 'hotfix/zf2-569'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Sep 19, 2012
2 parents ff5b442 + 49453f9 commit afac243
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/Zend/I18n/Validator/Float.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public function isValid($value)
$valueFiltered = str_replace($groupingSep, '', $value);
$valueFiltered = str_replace($decimalSep, '.', $valueFiltered);

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

if (strval($parsedFloat) !== $valueFiltered) {
$this->error(self::NOT_FLOAT);
return false;
Expand Down
2 changes: 2 additions & 0 deletions tests/ZendTest/I18n/Validator/FloatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function basicProvider()
array(0.01, true),
array(-0.1, true),
array('10.1', true),
array('10.0', true),
array('10.10', true),
array(1, true),
array('10.1not a float', false),
);
Expand Down

0 comments on commit afac243

Please sign in to comment.