public function betweenAction()
 {
     $v = new Zend_Validate_Between(array('min' => 1, 'max' => 12));
     $valor = 15;
     if ($v->isValid($valor)) {
         echo "{$valor} eh valido";
     } else {
         echo "{$valor} eh invalido";
         $erros = $v->getMessages();
         print_r($erros);
     }
     exit;
 }
 /**
  * set the max result hits for this search
  *
  * @param integer $hits
  * @return Zend_Service_DeveloperGarden_LocalSearch_SearchParameters
  */
 public function setHits($hits = 10)
 {
     require_once 'Zend/Validate/Between.php';
     $validator = new Zend_Validate_Between(0, 1000);
     if (!$validator->isValid($hits)) {
         $message = $validator->getMessages();
         require_once 'Zend/Service/DeveloperGarden/LocalSearch/Exception.php';
         throw new Zend_Service_DeveloperGarden_LocalSearch_Exception(current($message));
     }
     $this->_parameters['hits'] = $hits;
     return $this;
 }
Esempio n. 3
0
 /**
  * Sets img size
  *
  * @throws Zend_View_Exception
  * @param int $imgSize Size of img must be between 1 and 512
  * @return Zend_View_Helper_Gravatar
  */
 public function setImgSize($imgSize)
 {
     /**
      * @see Zend_Validate_Between
      */
     require_once 'Zend/Validate/Between.php';
     $betweenValidate = new Zend_Validate_Between(1, 512);
     $result = $betweenValidate->isValid($imgSize);
     if (!$result) {
         /**
          * @see Zend_View_Exception
          */
         require_once 'Zend/View/Exception.php';
         throw new Zend_View_Exception(current($betweenValidate->getMessages()));
     }
     $this->_options['imgSize'] = $imgSize;
     return $this;
 }
Esempio n. 4
0
 public function testSetGetMessageLengthLimitation()
 {
     Zend_Validate::setMessageLength(5);
     $this->assertEquals(5, Zend_Validate::getMessageLength());
     $valid = new Zend_Validate_Between(1, 10);
     $this->assertFalse($valid->isValid(24));
     $message = current($valid->getMessages());
     $this->assertTrue(strlen($message) <= 5);
 }
 /**
  * Ensures that getMessages() returns expected default value
  *
  * @return void
  */
 public function testGetMessages()
 {
     $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
     $this->assertEquals(array(), $validator->getMessages());
 }
Esempio n. 6
0
 /**
  * Sets img size
  *
  * @throws Zend_View_Exception
  * @param int $imgSize Size of img must be between 1 and 512
  * @return Zwe_View_Helper_Gravatar
  */
 public function setImgSize($imgSize)
 {
     $betweenValidate = new Zend_Validate_Between(1, 512);
     $result = $betweenValidate->isValid($imgSize);
     if (!$result) {
         throw new Zend_View_Exception(current($betweenValidate->getMessages()));
     }
     $this->_options['imgSize'] = $imgSize;
     return $this;
 }
Esempio n. 7
0
 public function isValidDocument($file, $max, $allowedTypes)
 {
     //check size
     $validator = new Zend_Validate_Between('1', $max);
     if ($validator->isValid($file['size'])) {
     } else {
         // value failed validation; print reasons
         foreach ($validator->getMessages() as $message) {
             return array('Error' => 'Document:' . $message);
         }
     }
     //check the type
     $this->_fileName = $file['name'];
     $return = $this->_checkType($allowedTypes);
     if ($return == false) {
         return array('Error' => 'Non-allowed type of document.');
     }
 }