import v1.1.0_RC2 | 2009-09-20
This commit is contained in:
@ -15,9 +15,9 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Validate
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Regex.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
* @version $Id: Regex.php 17470 2009-08-08 22:27:09Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -30,18 +30,19 @@ require_once 'Zend/Validate/Abstract.php';
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Validate
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Validate_Regex extends Zend_Validate_Abstract
|
||||
{
|
||||
|
||||
const INVALID = 'regexInvalid';
|
||||
const NOT_MATCH = 'regexNotMatch';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_messageTemplates = array(
|
||||
self::INVALID => "Invalid type given, value should be string, integer or float",
|
||||
self::NOT_MATCH => "'%value%' does not match against pattern '%pattern%'"
|
||||
);
|
||||
|
||||
@ -103,20 +104,20 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
$valueString = (string) $value;
|
||||
if (!is_string($value) && !is_int($value) && !is_float($value)) {
|
||||
$this->_error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_setValue($valueString);
|
||||
$this->_setValue($value);
|
||||
|
||||
$status = @preg_match($this->_pattern, $valueString);
|
||||
$status = @preg_match($this->_pattern, $value);
|
||||
if (false === $status) {
|
||||
/**
|
||||
* @see Zend_Validate_Exception
|
||||
*/
|
||||
require_once 'Zend/Validate/Exception.php';
|
||||
throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$valueString'");
|
||||
throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$value'");
|
||||
}
|
||||
if (!$status) {
|
||||
$this->_error();
|
||||
$this->_error(self::NOT_MATCH);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user