Index: Int.php =================================================================== --- Int.php (revision 9271) +++ Int.php (working copy) @@ -46,6 +46,24 @@ ); /** + * Should validation fail if the integer exceeds PHP boundaries + * + * @var boolean + */ + protected $_failOnPhpIntegerBoundary = true; + + /** + * Set wether or not the validation should fail if the integer exceeds + * PHP boundaries. See the PHP_INT_MAX constant. + * + * @param boolean $fail + */ + public function setFailOnPhpIntegerBoundary($fail = true) + { + $this->_failOnPhpIntegerBoundary = (bool) $fail; + } + + /** * Defined by Zend_Validate_Interface * * Returns true if and only if $value is a valid integer @@ -64,12 +82,24 @@ $valueFiltered = str_replace($locale['decimal_point'], '.', $valueString); $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered); - if (strval(intval($valueFiltered)) != $valueFiltered) { + // check if values exceed integer boundaries + if ((float) $valueString > PHP_INT_MAX and !$this->_failOnPhpIntegerBoundary) { + require_once 'Zend/Locale/Format.php'; + try { + $localeNumber = Zend_Locale_Format::toInteger($value); + if (!Zend_Locale_Format::isInteger($localeNumber)) { + $this->_error(); + return false; + } + } catch (Zend_Locale_Exception $e) { + $this->_error(); + return false; + } + } else if (strval(intval($valueFiltered)) != $valueFiltered) { $this->_error(); return false; } return true; } - }