diff -r 000000000000 -r 4eba9c11703f web/Zend/Validate/Hex.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Validate/Hex.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,72 @@ + "Invalid type given. String expected", + self::NOT_HEX => "'%value%' has not only hexadecimal digit characters", + ); + + /** + * Defined by Zend_Validate_Interface + * + * Returns true if and only if $value contains only hexadecimal digit characters + * + * @param string $value + * @return boolean + */ + public function isValid($value) + { + if (!is_string($value) && !is_int($value)) { + $this->_error(self::INVALID); + return false; + } + + $this->_setValue($value); + if (!ctype_xdigit((string) $value)) { + $this->_error(self::NOT_HEX); + return false; + } + + return true; + } + +}