Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Hex.php
Go to the documentation of this file.
1 <?php
25 #require_once 'Zend/Validate/Abstract.php';
26 
34 {
35  const INVALID = 'hexInvalid';
36  const NOT_HEX = 'notHex';
37 
43  protected $_messageTemplates = array(
44  self::INVALID => "Invalid type given. String expected",
45  self::NOT_HEX => "'%value%' has not only hexadecimal digit characters",
46  );
47 
56  public function isValid($value)
57  {
58  if (!is_string($value) && !is_int($value)) {
59  $this->_error(self::INVALID);
60  return false;
61  }
62 
63  $this->_setValue($value);
64  if (!ctype_xdigit((string) $value)) {
65  $this->_error(self::NOT_HEX);
66  return false;
67  }
68 
69  return true;
70  }
71 
72 }
isValid($value)
Definition: Hex.php:56
const NOT_HEX
Definition: Hex.php:36
_error($messageKey, $value=null)
Definition: Abstract.php:284
$value
Definition: gender.phtml:16
const INVALID
Definition: Hex.php:35