Skip to content
This repository
Browse code

Merge branch 'hotfix/zf2-569' into develop

Forward port #2388

Conflicts:
	library/Zend/I18n/Validator/Float.php
	tests/ZendTest/I18n/Validator/FloatTest.php
  • Loading branch information...
commit 14737f3be77ee98a257016f81bca6954c70ea6f1 2 parents 15fa021 + 49453f9
Matthew Weier O'Phinney weierophinney authored
8 library/Zend/I18n/Validator/Float.php
@@ -123,7 +123,13 @@ public function isValid($value)
123 123 $valueFiltered = str_replace($groupingSep, '', $value);
124 124 $valueFiltered = str_replace($decimalSep, '.', $valueFiltered);
125 125
126   - if (strval($parsedFloat) != $valueFiltered) {
  126 + while (strpos($valueFiltered, '.') !== false
  127 + && (substr($valueFiltered, -1) == '0' || substr($valueFiltered, -1) == '.')
  128 + ) {
  129 + $valueFiltered = substr($valueFiltered, 0, strlen($valueFiltered) - 1);
  130 + }
  131 +
  132 + if (strval($parsedFloat) !== $valueFiltered) {
127 133 $this->error(self::NOT_FLOAT);
128 134 return false;
129 135 }
2  tests/ZendTest/I18n/Validator/FloatTest.php
@@ -60,6 +60,8 @@ public function basicProvider()
60 60 array(-0.1, true),
61 61 array('10.1', true),
62 62 array('5.00', true),
  63 + array('10.0', true),
  64 + array('10.10', true),
63 65 array(1, true),
64 66 array('10.1not a float', false),
65 67 );

0 comments on commit 14737f3

Please sign in to comment.
Something went wrong with that request. Please try again.