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: Hex.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
* @version $Id: Hex.php 17470 2009-08-08 22:27:09Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -30,14 +30,12 @@ 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_Hex extends Zend_Validate_Abstract
|
||||
{
|
||||
/**
|
||||
* Validation failure message key for when the value contains characters other than hexadecimal digits
|
||||
*/
|
||||
const INVALID = 'hexInvalid';
|
||||
const NOT_HEX = 'notHex';
|
||||
|
||||
/**
|
||||
@ -46,6 +44,7 @@ class Zend_Validate_Hex extends Zend_Validate_Abstract
|
||||
* @var array
|
||||
*/
|
||||
protected $_messageTemplates = array(
|
||||
self::INVALID => "Invalid type given, value should be a string",
|
||||
self::NOT_HEX => "'%value%' has not only hexadecimal digit characters"
|
||||
);
|
||||
|
||||
@ -59,12 +58,14 @@ class Zend_Validate_Hex extends Zend_Validate_Abstract
|
||||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
$valueString = (string) $value;
|
||||
if (!is_string($value) && !is_int($value)) {
|
||||
$this->_error(self::INVALID);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->_setValue($valueString);
|
||||
|
||||
if (!ctype_xdigit($valueString)) {
|
||||
$this->_error();
|
||||
$this->_setValue($value);
|
||||
if (!ctype_xdigit((string) $value)) {
|
||||
$this->_error(self::NOT_HEX);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user