diff --git a/library/Zend/I18n/Validator/Float.php b/library/Zend/I18n/Validator/Float.php index db16805fb54..010a7d8446f 100644 --- a/library/Zend/I18n/Validator/Float.php +++ b/library/Zend/I18n/Validator/Float.php @@ -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; diff --git a/tests/ZendTest/I18n/Validator/FloatTest.php b/tests/ZendTest/I18n/Validator/FloatTest.php index 83478945466..c9f82e275d6 100644 --- a/tests/ZendTest/I18n/Validator/FloatTest.php +++ b/tests/ZendTest/I18n/Validator/FloatTest.php @@ -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), );