Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Validator / Hex.php
blob32311db16b0270d2946d5b06c2504b75c857dd62
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Validator;
12 class Hex extends AbstractValidator
14 const INVALID = 'hexInvalid';
15 const NOT_HEX = 'notHex';
17 /**
18 * Validation failure message template definitions
20 * @var array
22 protected $messageTemplates = array(
23 self::INVALID => "Invalid type given. String expected",
24 self::NOT_HEX => "The input contains non-hexadecimal characters",
27 /**
28 * Returns true if and only if $value contains only hexadecimal digit characters
30 * @param string $value
31 * @return bool
33 public function isValid($value)
35 if (!is_string($value) && !is_int($value)) {
36 $this->error(self::INVALID);
37 return false;
40 $this->setValue($value);
41 if (!ctype_xdigit((string) $value)) {
42 $this->error(self::NOT_HEX);
43 return false;
46 return true;