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

Public Member Functions

 __construct ($options)
 
 getMin ()
 
 setMin ($min)
 
 getMax ()
 
 setMax ($max)
 
 getInclusive ()
 
 setInclusive ($inclusive)
 
 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 NOT_BETWEEN = 'notBetween'
 
const NOT_BETWEEN_STRICT = 'notBetweenStrict'
 

Protected Attributes

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

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)
 
- Static Protected Attributes inherited from Zend_Validate_Abstract
static $_defaultTranslator
 
static $_messageLength = -1
 

Detailed Description

Definition at line 33 of file Between.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $options)

Sets validator options Accepts the following option keys: 'min' => scalar, minimum border 'max' => scalar, maximum border 'inclusive' => boolean, inclusive border values

Parameters
array | Zend_Config$options
Exceptions
Zend_Validate_Exception

Definition at line 99 of file Between.php.

100  {
101  if ($options instanceof Zend_Config) {
102  $options = $options->toArray();
103  } else if (!is_array($options)) {
104  $options = func_get_args();
105  $temp['min'] = array_shift($options);
106  if (!empty($options)) {
107  $temp['max'] = array_shift($options);
108  }
109 
110  if (!empty($options)) {
111  $temp['inclusive'] = array_shift($options);
112  }
113 
114  $options = $temp;
115  }
116 
117  if (!array_key_exists('min', $options) || !array_key_exists('max', $options)) {
118  #require_once 'Zend/Validate/Exception.php';
119  throw new Zend_Validate_Exception("Missing option. 'min' and 'max' has to be given");
120  }
121 
122  if (!array_key_exists('inclusive', $options)) {
123  $options['inclusive'] = true;
124  }
125 
126  $this->setMin($options['min'])
127  ->setMax($options['max'])
128  ->setInclusive($options['inclusive']);
129  }

Member Function Documentation

◆ getInclusive()

getInclusive ( )

Returns the inclusive option

Returns
boolean

Definition at line 180 of file Between.php.

181  {
182  return $this->_inclusive;
183  }

◆ getMax()

getMax ( )

Returns the max option

Returns
mixed

Definition at line 158 of file Between.php.

159  {
160  return $this->_max;
161  }

◆ getMin()

getMin ( )

Returns the min option

Returns
mixed

Definition at line 136 of file Between.php.

137  {
138  return $this->_min;
139  }

◆ isValid()

isValid (   $value)

Defined by Zend_Validate_Interface

Returns true if and only if $value is between min and max options, inclusively if inclusive option is true.

Parameters
mixed$value
Returns
boolean

Implements Zend_Validate_Interface.

Definition at line 206 of file Between.php.

207  {
208  $this->_setValue($value);
209 
210  if ($this->_inclusive) {
211  if ($this->_min > $value || $value > $this->_max) {
212  $this->_error(self::NOT_BETWEEN);
213  return false;
214  }
215  } else {
216  if ($this->_min >= $value || $value >= $this->_max) {
217  $this->_error(self::NOT_BETWEEN_STRICT);
218  return false;
219  }
220  }
221  return true;
222  }
_error($messageKey, $value=null)
Definition: Abstract.php:284
$value
Definition: gender.phtml:16

◆ setInclusive()

setInclusive (   $inclusive)

Sets the inclusive option

Parameters
boolean$inclusive
Returns
Zend_Validate_Between Provides a fluent interface

Definition at line 191 of file Between.php.

192  {
193  $this->_inclusive = $inclusive;
194  return $this;
195  }

◆ setMax()

setMax (   $max)

Sets the max option

Parameters
mixed$max
Returns
Zend_Validate_Between Provides a fluent interface

Definition at line 169 of file Between.php.

170  {
171  $this->_max = $max;
172  return $this;
173  }

◆ setMin()

setMin (   $min)

Sets the min option

Parameters
mixed$min
Returns
Zend_Validate_Between Provides a fluent interface

Definition at line 147 of file Between.php.

148  {
149  $this->_min = $min;
150  return $this;
151  }

Field Documentation

◆ $_inclusive

$_inclusive
protected

Definition at line 87 of file Between.php.

◆ $_max

$_max
protected

Definition at line 77 of file Between.php.

◆ $_messageTemplates

$_messageTemplates
protected
Initial value:
= array(
self::NOT_BETWEEN => "'%value%' is not between '%min%' and '%max%', inclusively",
self::NOT_BETWEEN_STRICT => "'%value%' is not strictly between '%min%' and '%max%'"
)

Definition at line 50 of file Between.php.

◆ $_messageVariables

$_messageVariables
protected
Initial value:
= array(
'min' => '_min',
'max' => '_max'
)

Definition at line 60 of file Between.php.

◆ $_min

$_min
protected

Definition at line 70 of file Between.php.

◆ NOT_BETWEEN

const NOT_BETWEEN = 'notBetween'

Validation failure message key for when the value is not between the min and max, inclusively

Definition at line 38 of file Between.php.

◆ NOT_BETWEEN_STRICT

const NOT_BETWEEN_STRICT = 'notBetweenStrict'

Validation failure message key for when the value is not strictly between the min and max

Definition at line 43 of file Between.php.


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