|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00025 require_once 'Zend/Validate/Abstract.php'; 00026 00033 class Zend_Validate_LessThan extends Zend_Validate_Abstract 00034 { 00035 const NOT_LESS = 'notLessThan'; 00036 00040 protected $_messageTemplates = array( 00041 self::NOT_LESS => "'%value%' is not less than '%max%'" 00042 ); 00043 00047 protected $_messageVariables = array( 00048 'max' => '_max' 00049 ); 00050 00056 protected $_max; 00057 00064 public function __construct($max) 00065 { 00066 if ($max instanceof Zend_Config) { 00067 $max = $max->toArray(); 00068 } 00069 00070 if (is_array($max)) { 00071 if (array_key_exists('max', $max)) { 00072 $max = $max['max']; 00073 } else { 00074 require_once 'Zend/Validate/Exception.php'; 00075 throw new Zend_Validate_Exception("Missing option 'max'"); 00076 } 00077 } 00078 00079 $this->setMax($max); 00080 } 00081 00087 public function getMax() 00088 { 00089 return $this->_max; 00090 } 00091 00098 public function setMax($max) 00099 { 00100 $this->_max = $max; 00101 return $this; 00102 } 00103 00112 public function isValid($value) 00113 { 00114 $this->_setValue($value); 00115 if ($this->_max <= $value) { 00116 $this->_error(self::NOT_LESS); 00117 return false; 00118 } 00119 return true; 00120 } 00121 00122 }