Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/zf2-569' into develop
Browse files Browse the repository at this point in the history
Forward port #2388

Conflicts:
	library/Zend/I18n/Validator/Float.php
	tests/ZendTest/I18n/Validator/FloatTest.php
  • Loading branch information
weierophinney committed Sep 19, 2012
2 parents 15fa021 + 49453f9 commit 14737f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/Zend/I18n/Validator/Float.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ public function isValid($value)
$valueFiltered = str_replace($groupingSep, '', $value);
$valueFiltered = str_replace($decimalSep, '.', $valueFiltered);

if (strval($parsedFloat) != $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 @@ -60,6 +60,8 @@ public function basicProvider()
array(-0.1, true),
array('10.1', true),
array('5.00', true),
array('10.0', true),
array('10.10', true),
array(1, true),
array('10.1not a float', false),
);
Expand Down

0 comments on commit 14737f3

Please sign in to comment.