• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Validate_Between类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: _validateItemLookup

 /**
  * Validate options for an ItemLookup
  *
  * @param array $options Options array to be used for the query
  * @throws Zend_Service_Exception
  * @return void
  */
 protected function _validateItemLookup($options = array())
 {
     if (!is_array($options)) {
         throw new Zend_Service_Exception('Options must be specified as an array');
     }
     // Validate keys in the $options array
     $this->_compareOptions($options, array('ItemId', 'IdType', 'SearchIndex', 'MerchantId', 'Condition', 'DeliveryMethod', 'ISPUPostalCode', 'OfferPage', 'ReviewPage', 'VariationPage', 'ResponseGroup', 'Service', 'SubscriptionId', 'Operation'));
     // Validate ResponseGroup (required)
     if (empty($options['ResponseGroup'])) {
         throw new Zend_Service_Exception('Query requires a ResponseGroup');
     } else {
         $responseGroup = split(',', $options['ResponseGroup']);
         foreach ($responseGroup as $r) {
             if (!in_array($r, array('Request', 'Small', 'Medium', 'Large'))) {
                 throw new Zend_Service_Exception('This wrapper only supports Request, Small, Medium and Large ' . 'ResponseGroups');
             }
         }
     }
     // Validate Sort (optional)
     if (isset($options['Sort'])) {
         $this->_validateInArray('Sort', $options['Sort'], array_values(self::$_searchSort[$options['SearchIndex']]));
     }
     // Validate City (optional)
     if (isset($options['City'])) {
         $this->_validateInArray('City', $options['City'], array('Boston', 'Chicago', 'New York', 'San Francisco', 'Seattle', 'Washington, D.C.'));
     }
     if (isset($options['ItemPage'])) {
         /**
          * @see Zend_Validate_Between
          */
         require_once 'Zend/Validate/Between.php';
         $between = new Zend_Validate_Between(0, 2500, true);
         if (!$between->isValid($options['ItemPage'])) {
             throw new Zend_Service_Exception($options['ItemPage'] . ' is not a valid value for the "ItemPage" option.');
         }
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:44,代码来源:Amazon.php


示例17: between

 public function between($min, $max, $value)
 {
     $validator = new Zend_Validate_Between(array('min' => $min, 'max' => $max));
     return $validator->isValid($value);
 }
开发者ID:papermache,项目名称:elmhurst_backend,代码行数:5,代码来源:tidy.compress.php


示例18: _prepareVideoSourceArguments

 /**
  * Prepares the arguments for the "Video" source
  *
  * @param array $options 
  * @return array
  */
 protected function _prepareVideoSourceArguments(array $options = array())
 {
     $arguments = array();
     if (isset($options['count'])) {
         $between = new Zend_Validate_Between(1, 50, true);
         if (!$between->isValid($options['count'])) {
             throw new Zend_Service_Exception($options['count'] . ' is not valid for the "count" option');
         }
         $arguments['Video.Count'] = (int) $options['count'];
     }
     if (isset($options['offset'])) {
         $between = new Zend_Validate_Between(0, 1000, true);
         if (!$between->isValid($options['offset'])) {
             throw new Zend_Service_Exception($options['offset'] . ' is not valid for the "offset" option');
         }
         $arguments['Video.Offset'] = (int) $options['offset'];
     }
     if (isset($options['adult'])) {
         $arguments['Video.Adult'] = $options['adult'];
     }
     if (isset($options['filters'])) {
         if (is_string($options['filters'])) {
             $options['filters'] = array($options['filters']);
         }
         if (!is_array($options['filters'])) {
             throw new Zend_Service_Exception('The "filters" option must be a string or array of strings');
         }
         $arguments['Video.Filters'] = implode(',', $options['filters']);
     }
     if (isset($options['sortby'])) {
         $arguments['Video.SortBy'] = $options['sortby'];
     }
     return $arguments;
 }
开发者ID:noginn,项目名称:Noginn_Service_Bing,代码行数:40,代码来源:Bing.php


示例19: testGetInclusive

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


示例20: overrideBetweenValidator

 public static function overrideBetweenValidator($p_min, $p_max)
 {
     $validator = new Zend_Validate_Between($p_min, $p_max, true);
     $validator->setMessage(_("'%value%' is not between '%min%' and '%max%', inclusively"), Zend_Validate_Between::NOT_BETWEEN);
     return $validator;
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:6,代码来源:ValidationTypes.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Validate_Date类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Validate_Barcode_AdapterAbstract类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap