Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes | Static Protected Attributes
Zend_Validate_Alnum Class Reference
Inheritance diagram for Zend_Validate_Alnum:
Zend_Validate_Abstract Zend_Validate_Interface Alnum Alnum

Public Member Functions

 __construct ($allowWhiteSpace=false)
 
 getAllowWhiteSpace ()
 
 setAllowWhiteSpace ($allowWhiteSpace)
 
 isValid ($value)
 
- Public Member Functions inherited from Zend_Validate_Abstract
 getMessages ()
 
 getMessageVariables ()
 
 getMessageTemplates ()
 
 setMessage ($messageString, $messageKey=null)
 
 setMessages (array $messages)
 
 __get ($property)
 
 getErrors ()
 
 setObscureValue ($flag)
 
 getObscureValue ()
 
 setTranslator ($translator=null)
 
 getTranslator ()
 
 hasTranslator ()
 
 setDisableTranslator ($flag)
 
 translatorIsDisabled ()
 

Data Fields

const INVALID = 'alnumInvalid'
 
const NOT_ALNUM = 'notAlnum'
 
const STRING_EMPTY = 'alnumStringEmpty'
 
 $allowWhiteSpace
 

Protected Attributes

 $_messageTemplates
 
- Protected Attributes inherited from Zend_Validate_Abstract
 $_value
 
 $_messageVariables = array()
 
 $_messageTemplates = array()
 
 $_messages = array()
 
 $_obscureValue = false
 
 $_errors = array()
 
 $_translator
 
 $_translatorDisabled = false
 

Static Protected Attributes

static $_filter = null
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Validate_Abstract
static setDefaultTranslator ($translator=null)
 
static getDefaultTranslator ()
 
static hasDefaultTranslator ()
 
static getMessageLength ()
 
static setMessageLength ($length=-1)
 
- Protected Member Functions inherited from Zend_Validate_Abstract
 _createMessage ($messageKey, $value)
 
 _implodeRecursive (array $pieces)
 
 _error ($messageKey, $value=null)
 
 _setValue ($value)
 

Detailed Description

Definition at line 33 of file Alnum.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $allowWhiteSpace = false)

Sets default option values for this instance

Parameters
boolean | Zend_Config$allowWhiteSpace

Definition at line 70 of file Alnum.php.

71  {
72  if ($allowWhiteSpace instanceof Zend_Config) {
74  }
75 
76  if (is_array($allowWhiteSpace)) {
77  if (array_key_exists('allowWhiteSpace', $allowWhiteSpace)) {
78  $allowWhiteSpace = $allowWhiteSpace['allowWhiteSpace'];
79  } else {
80  $allowWhiteSpace = false;
81  }
82  }
83 
84  $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
85  }

Member Function Documentation

◆ getAllowWhiteSpace()

getAllowWhiteSpace ( )

Returns the allowWhiteSpace option

Returns
boolean

Definition at line 92 of file Alnum.php.

93  {
95  }

◆ isValid()

isValid (   $value)

Defined by Zend_Validate_Interface

Returns true if and only if $value contains only alphabetic and digit characters

Parameters
string$value
Returns
boolean
See also
Zend_Filter_Alnum

Implements Zend_Validate_Interface.

Definition at line 117 of file Alnum.php.

118  {
119  if (!is_string($value) && !is_int($value) && !is_float($value)) {
120  $this->_error(self::INVALID);
121  return false;
122  }
123 
124  $this->_setValue($value);
125 
126  if ('' === $value) {
127  $this->_error(self::STRING_EMPTY);
128  return false;
129  }
130 
131  if (null === self::$_filter) {
135  #require_once 'Zend/Filter/Alnum.php';
136  self::$_filter = new Zend_Filter_Alnum();
137  }
138 
139  self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;
140 
141  if ($value != self::$_filter->filter($value)) {
142  $this->_error(self::NOT_ALNUM);
143  return false;
144  }
145 
146  return true;
147  }
_error($messageKey, $value=null)
Definition: Abstract.php:284
$value
Definition: gender.phtml:16

◆ setAllowWhiteSpace()

setAllowWhiteSpace (   $allowWhiteSpace)

Sets the allowWhiteSpace option

Parameters
boolean$allowWhiteSpace
Returns
Zend_Filter_Alnum Provides a fluent interface

Definition at line 103 of file Alnum.php.

104  {
105  $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
106  return $this;
107  }

Field Documentation

◆ $_filter

$_filter = null
staticprotected

Definition at line 52 of file Alnum.php.

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::INVALID => "Invalid type given. String, integer or float expected",
self::NOT_ALNUM => "'%value%' contains characters which are non alphabetic and no digits",
self::STRING_EMPTY => "'%value%' is an empty string",
)

Definition at line 59 of file Alnum.php.

◆ $allowWhiteSpace

$allowWhiteSpace

Definition at line 45 of file Alnum.php.

◆ INVALID

const INVALID = 'alnumInvalid'

Definition at line 35 of file Alnum.php.

◆ NOT_ALNUM

const NOT_ALNUM = 'notAlnum'

Definition at line 36 of file Alnum.php.

◆ STRING_EMPTY

const STRING_EMPTY = 'alnumStringEmpty'

Definition at line 37 of file Alnum.php.


The documentation for this class was generated from the following file: