|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00025 require_once 'Zend/Validate/Abstract.php'; 00026 00033 class Zend_Validate_Hex extends Zend_Validate_Abstract 00034 { 00035 const INVALID = 'hexInvalid'; 00036 const NOT_HEX = 'notHex'; 00037 00043 protected $_messageTemplates = array( 00044 self::INVALID => "Invalid type given, value should be a string", 00045 self::NOT_HEX => "'%value%' has not only hexadecimal digit characters", 00046 ); 00047 00056 public function isValid($value) 00057 { 00058 if (!is_string($value) && !is_int($value)) { 00059 $this->_error(self::INVALID); 00060 return false; 00061 } 00062 00063 $this->_setValue($value); 00064 if (!ctype_xdigit((string) $value)) { 00065 $this->_error(self::NOT_HEX); 00066 return false; 00067 } 00068 00069 return true; 00070 } 00071 00072 }