|
|
@@ -57,7 +57,9 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
|
|
|
*/
|
|
|
public function __construct($locale = null)
|
|
|
{
|
|
|
- $this->setLocale($locale);
|
|
|
+ if ($locale !== null) {
|
|
|
+ $this->setLocale($locale);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -96,15 +98,27 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
|
|
|
}
|
|
|
|
|
|
$this->_setValue($value);
|
|
|
- try {
|
|
|
- if (!Zend_Locale_Format::isFloat($value, array('locale' => 'en')) &&
|
|
|
- !Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
|
|
|
+ if ($this->_locale === null) {
|
|
|
+ $locale = localeconv();
|
|
|
+ $valueFiltered = str_replace($locale['thousands_sep'], '', (string) $value);
|
|
|
+ $valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered);
|
|
|
+
|
|
|
+ if (strval(floatval($valueFiltered)) != $valueFiltered) {
|
|
|
+ $this->_error();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ if (!Zend_Locale_Format::isFloat($value, array('locale' => 'en')) &&
|
|
|
+ !Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
|
|
|
+ $this->_error();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } catch (Zend_Locale_Exception $e) {
|
|
|
$this->_error();
|
|
|
return false;
|
|
|
}
|
|
|
- } catch (Zend_Locale_Exception $e) {
|
|
|
- $this->_error();
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
return true;
|