当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Validate_Between类代码示例

本文整理汇总了PHP中Zend_Validate_Between的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Between类的具体用法?PHP Zend_Validate_Between怎么用?PHP Zend_Validate_Between使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Validate_Between类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 public function init()
 {
     parent::init();
     if (is_null($this->getAttrib('size'))) {
         $this->setAttrib('size', 6);
     }
     $validator = new Zend_Validate_Int();
     $validator->setMessage('validation_error_int');
     $this->addValidator($validator);
     $options = array();
     $min = $this->getAttrib('min');
     if (is_null($min)) {
         $min = 0;
     } else {
         $this->setAttrib('min', null);
         // remove from rendered attributes
     }
     $options['min'] = $min;
     $max = $this->getAttrib('max');
     if (is_null($max)) {
         $validator = new Zend_Validate_GreaterThan(array('min' => $min - 1));
         // inclusive not supported in ZF1
         $validator->setMessage('validation_error_number_tooSmall');
     } else {
         $this->setAttrib('max', null);
         // remove from rendered attributes
         $options['max'] = $max;
         $validator = new Zend_Validate_Between(array('min' => $min, 'max' => $max));
         $validator->setMessage('validation_error_number_notBetween');
     }
     $this->addValidator($validator);
 }
开发者ID:belapp,项目名称:opus4-application,代码行数:32,代码来源:Number.php

示例2: _beforeSave

 public function _beforeSave()
 {
     $valid = new Zend_Validate_Between(array('min' => 1, 'max' => 100));
     if (!$valid->isValid($this->getValue())) {
         $this->_dataSaveAllowed = false;
         Mage::throwException(Mage::helper('welance_kraken')->__('Please use a value between 1 and 100'));
     }
     return parent::_beforeSave();
 }
开发者ID:fasimana,项目名称:kraken-magento,代码行数:9,代码来源:Quality.php

示例3: betweenAction

 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;
 }
开发者ID:JoaoAntonioMaruti,项目名称:AulasUnipar2015,代码行数:13,代码来源:ValidadorController.php

示例4: isValidDocument

 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.');
     }
 }
开发者ID:roycocup,项目名称:Tests,代码行数:18,代码来源:Validator.php

示例5: testBasic

 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     /**
      * The elements of each array are, in order:
      *      - minimum
      *      - maximum
      *      - inclusive
      *      - expected validation result
      *      - array of test input values
      */
     $valuesExpected = array(array(1, 100, true, true, array(1, 10, 100)), array(1, 100, false, false, array(0, 1, 100, 101)), array('a', 'z', true, true, array('a', 'b', 'y', 'z')), array('a', 'z', false, false, array('!', 'a', 'z')));
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_Between($element[0], $element[1], $element[2]);
         foreach ($element[4] as $input) {
             $this->assertEquals($element[3], $validator->isValid($input));
         }
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:23,代码来源:BetweenTest.php

示例6: setImgSize

 /**
  * 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;
 }
开发者ID:BGCX262,项目名称:zweer-gdr-svn-to-git,代码行数:17,代码来源:Gravatar.php

示例7: __construct

 /**
  * Sets validator options
  * Accepts the following option keys:
  *   'min' => scalar, minimum border
  *   'max' => scalar, maximum border
  *   'inclusive' => boolean, inclusive border values
  * @override
  * @param array|\Zend_Config $options
  */
 public function __construct(array $options)
 {
     /**
      * Спецификация конструктора класса Zend_Validate_Between
      * различается между Zend Framework 1.9.6 (Magento 1.4.0.1)
      * и Zend Framework 1.11.1 (Magento 1.5.0.1).
      *
      * Именно для устранения для пользователя данных различий
      * служит наш класс-посредник \Df\Zf\Validate\Between
      */
     if (version_compare(\Zend_Version::VERSION, '1.10', '>=')) {
         /** @noinspection PhpParamsInspection */
         parent::__construct($options);
     } else {
         /** @noinspection PhpParamsInspection */
         parent::__construct(dfa($options, 'min'), dfa($options, 'max'), dfa($options, 'inclusive'));
     }
 }
开发者ID:mage2pro,项目名称:core,代码行数:27,代码来源:Between.php

示例8: setImgSize

 /**
  * 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;
 }
开发者ID:kminkov,项目名称:Blog,代码行数:25,代码来源:Gravatar.php

示例9: between

 /**
  * Built-in Zend between check.  Returns true if and only if $value is between the minimum and maximum boundary values.
  *
  * @param integer $value
  * @param integer $min
  * @param mixed $max
  * @param boolean $inclusive
  *
  * @return boolean Valid?
  */
 public function between($value, $min, $max, $inclusive = true)
 {
     $this->m_ErrorMessage = null;
     require_once 'Zend/Validate/Between.php';
     $validator = new Zend_Validate_Between($min, $max, $inclusive);
     $result = $validator->isValid($value);
     if (!$result) {
         $this->m_ErrorMessage = BizSystem::getMessage("VALIDATESVC_BETWEEN", array($this->m_FieldNameMask, $min, $max));
     }
     return $result;
 }
开发者ID:que273,项目名称:siremis,代码行数:21,代码来源:validateService.php

示例10: testSetGetMessageLengthLimitation

 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);
 }
开发者ID:netvlies,项目名称:zf,代码行数:9,代码来源:ValidateTest.php

示例11: _getValidatorBetween

 /**
  *
  * @param type $min
  * @param type $max
  * @param type $messages_prefixed
  * @return \Zend_Validate_Between 
  */
 protected function _getValidatorBetween($min = 5, $max = 100, $messages_prefixed = "")
 {
     $between = new Zend_Validate_Between(array('min' => $min, 'max' => $max));
     $between->setMessage(sprintf($this->_translate('ERROR_BETWEEN'), $this->_translate($messages_prefixed), $min, $max), Zend_Validate_Between::NOT_BETWEEN);
     return $between;
 }
开发者ID:BGCX067,项目名称:facebook-store-svn-to-git,代码行数:13,代码来源:Form.php

示例12: testGetInclusive

 /**
  * Ensures that getInclusive() returns expected default value
  *
  * @return void
  */
 public function testGetInclusive()
 {
     $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
     $this->assertEquals(true, $validator->getInclusive());
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:10,代码来源:BetweenTest.php

示例13: _validateWebSearch

 /**
  * Validate Web Search Options
  *
  * @param  array $options
  * @return void
  * @throws Zend_Service_Exception
  */
 protected function _validateWebSearch(array $options)
 {
     $validOptions = array('appid', 'query', 'results', 'start', 'language', 'type', 'format', 'adult_ok', 'similar_ok', 'country', 'site', 'subscription', 'license', 'region');
     $this->_compareOptions($options, $validOptions);
     /**
      * @see Zend_Validate_Between
      */
     //require_once 'Zend/Validate/Between.php';
     $between = new Zend_Validate_Between(1, 100, true);
     if (isset($options['results']) && !$between->setMin(1)->setMax(100)->isValid($options['results'])) {
         /**
          * @see Zend_Service_Exception
          */
         //require_once 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception("Invalid value for option 'results': {$options['results']}");
     }
     if (isset($options['start']) && !$between->setMin(1)->setMax(1000)->isValid($options['start'])) {
         /**
          * @see Zend_Service_Exception
          */
         //require_once 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception("Invalid value for option 'start': {$options['start']}");
     }
     if (isset($options['language'])) {
         $this->_validateLanguage($options['language']);
     }
     $this->_validateInArray('type', $options['type'], array('all', 'any', 'phrase'));
     $this->_validateInArray('format', $options['format'], array('any', 'html', 'msword', 'pdf', 'ppt', 'rss', 'txt', 'xls'));
     if (isset($options['license'])) {
         $this->_validateInArray('license', $options['license'], array('any', 'cc_any', 'cc_commercial', 'cc_modifiable'));
     }
     if (isset($options['region'])) {
         $this->_validateInArray('region', $options['region'], array('ar', 'au', 'at', 'br', 'ca', 'ct', 'dk', 'fi', 'fr', 'de', 'in', 'id', 'it', 'my', 'mx', 'nl', 'no', 'ph', 'ru', 'sg', 'es', 'se', 'ch', 'th', 'uk', 'us'));
     }
 }
开发者ID:schlypel,项目名称:YiiBackboneBoilerplate,代码行数:42,代码来源:Yahoo.php

示例14: _validateTagSearch

 /**
  * Validate Tag Search Options
  *
  * @param  array $options
  * @throws Zend_Service_Exception
  * @return void
  */
 protected function _validateTagSearch(array $options)
 {
     $validOptions = array('method', 'api_key', 'user_id', 'tags', 'tag_mode', 'text', 'min_upload_date', 'max_upload_date', 'min_taken_date', 'max_taken_date', 'license', 'sort', 'privacy_filter', 'bbox', 'accuracy', 'machine_tags', 'machine_tag_mode', 'group_id', 'extras', 'per_page', 'page');
     $this->_compareOptions($options, $validOptions);
     /**
      * @see Zend_Validate_Between
      */
     require_once 'Zend/Validate/Between.php';
     $between = new Zend_Validate_Between(1, 500, true);
     if (!$between->isValid($options['per_page'])) {
         /**
          * @see Zend_Service_Exception
          */
         require_once 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception($options['per_page'] . ' is not valid for the "per_page" option');
     }
     /**
      * @see Zend_Validate_Int
      */
     require_once 'Zend/Validate/Int.php';
     $int = new Zend_Validate_Int();
     if (!$int->isValid($options['page'])) {
         /**
          * @see Zend_Service_Exception
          */
         require_once 'Zend/Service/Exception.php';
         throw new Zend_Service_Exception($options['page'] . ' is not valid for the "page" option');
     }
     // validate extras, which are delivered in csv format
     if ($options['extras']) {
         $extras = explode(',', $options['extras']);
         $validExtras = array('license', 'date_upload', 'date_taken', 'owner_name', 'icon_server');
         foreach ($extras as $extra) {
             /**
              * @todo The following does not do anything [yet], so it is commented out.
              */
             //in_array(trim($extra), $validExtras);
         }
     }
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:47,代码来源:Flickr.php

示例15: setHits

 /**
  * 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;
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:18,代码来源:SearchParameters.php


注:本文中的Zend_Validate_Between类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。