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


PHP Zend_Validate_Between::isValid方法代码示例

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


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

示例1: isValid

 public function isValid($value)
 {
     if ($value == '-') {
         return true;
     }
     return parent::isValid($value);
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:7,代码来源:ApnIndex.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: 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, true, false, array(0, 0.99, 100.01, 101)), 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(array('min' => $element[0], 'max' => $element[1], 'inclusive' => $element[2]));
         foreach ($element[4] as $input) {
             $this->assertEquals($element[3], $validator->isValid($input), 'Failed values: ' . $input . ":" . implode("\n", $validator->getMessages()));
         }
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:23,代码来源:BetweenTest.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: 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

示例7: _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

示例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: 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

示例10: 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

示例11: _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

示例12: _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

示例13: 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

示例14: isBetween

 /**
  * Returns TRUE if value is greater than or equal to $min and less
  * than or equal to $max, FALSE otherwise. If $inc is set to
  * FALSE, then the value must be strictly greater than $min and
  * strictly less than $max.
  *
  * @deprecated since 0.8.0
  * @param      mixed $key
  * @param      mixed $min
  * @param      mixed $max
  * @param      boolean $inc
  * @return     boolean
  */
 public static function isBetween($value, $min, $max, $inc = true)
 {
     require_once 'Zend/Validate/Between.php';
     $validator = new Zend_Validate_Between($min, $max, $inc);
     return $validator->isValid($value);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:19,代码来源:Filter.php

示例15: validateAndSave

 protected function validateAndSave($facilityRow, $checkName = true)
 {
     $districtText = $this->tr('Region B (Health District)');
     $provinceText = $this->tr('Region A (Province)');
     $localRegionText = $this->tr('Region C (Local Region)');
     //validate
     $status = ValidationContainer::instance();
     //check for required fields
     if ($checkName) {
         $status->checkRequired($this, 'facility_name', 'Facility name');
         //check for unique
         if ($this->_getParam('facility_name') and !Facility::isUnique($this->_getParam('facility_name'), $this->_getParam('id'))) {
             $status->addError('facility_name', t('That name already exists.'));
         }
     }
     // validate lat & long
     require_once 'Zend/Validate/Float.php';
     require_once 'Zend/Validate/Between.php';
     $lat = $this->getSanParam('facility_latitude');
     $long = $this->getSanParam('facility_longitude');
     $validator = new Zend_Validate_Float();
     $validbetween = new Zend_Validate_Between('-180', '180');
     if ($lat && (!$validator->isValid($lat) || !$validbetween->isValid($lat))) {
         $status->addError('facility_latitude', t('That latitude and longitude does not appear to be valid.'));
     }
     if ($long && (!$validator->isValid($long) || !$validbetween->isValid($long))) {
         $status->addError('facility_longitude', t('That latitude and longitude does not appear to be valid.'));
     }
     $status->checkRequired($this, 'facility_type_id', t('Facility type'));
     $status->checkRequired($this, 'facility_province_id', $provinceText);
     if ($this->setting('display_region_b')) {
         $status->checkRequired($this, 'facility_district_id', $districtText);
     }
     if ($this->setting('display_region_c')) {
         $status->checkRequired($this, 'facility_region_c_id', $localRegionText);
     }
     //$status->checkRequired ( $this, 'facility_city', t ( "City is required." ) );
     list($location_params, $facility_location_tier, $facility_location_id) = $this->getLocationCriteriaValues(array(), 'facility');
     $city_id = false;
     if ($this->getSanParam('facility_city') && !$this->getSanParam('is_new_city')) {
         $city_id = Location::verifyHierarchy($location_params['facility_city'], $location_params['facility_city_parent_id'], $this->setting('num_location_tiers'));
         if ($city_id === false) {
             $status->addError('facility_city', t("That city does not appear to be located in the chosen region. If you want to create a new city, check the new city box."));
         }
     }
     $sponsor_date_array = $this->getSanParam('sponsor_start_date');
     // may or may not be array
     $sponsor_end_date_array = $this->getSanParam('sponsor_end_date');
     $sponsor_id = $this->getSanParam('facility_sponsor_id') ? $this->getSanParam('facility_sponsor_id') : null;
     if (is_array($sponsor_id)) {
         $sponsor_array = $sponsor_id;
         $sponsor_id = $sponsor_id[0];
     }
     // todo case where multip array and no_allow_multi
     if (@$this->setting('require_sponsor_dates')) {
         $status->checkRequired($this, 'sponsor_option_id', t('Sponsor dates are required.') . "\n");
         if ($this->setting('allow_multi_sponsors')) {
             // and multiple sponsors option
             if (!is_array($this->getSanParam('sponsor_option_id'))) {
                 $status->addError('sponsor_end_date', t('Sponsor dates are required.') . "\n");
             }
             foreach ($sponsor_array as $i => $val) {
                 if (empty($sponsor_date_array[$i]) || !empty($val)) {
                     $status->addError('sponsor_start_date', t('Sponsor dates are required.') . "\n");
                 }
                 if (empty($sponsor_end_date_array[$i]) || !empty($val)) {
                     $status->addError('sponsor_end_date', t('Sponsor dates are required.') . "\n");
                 }
             }
         }
     }
     // end validation
     if ($status->hasError()) {
         $status->setStatusMessage(t('The facility could not be saved.'));
     } else {
         $location_id = null;
         if ($city_id === false && $this->getSanParam('is_new_city')) {
             $location_id = Location::insertIfNotFound($location_params['facility_city'], $location_params['facility_city_parent_id'], $this->setting('num_location_tiers'));
             if ($location_id === false) {
                 $status->addError('facility_city', t('Could not save that city.'));
             }
         } else {
             if ($city_id) {
                 $location_id = $city_id;
             } else {
                 if ($this->setting('display_region_c')) {
                     $location_id = $this->getSanParam('facility_region_c_id');
                 } else {
                     if ($this->setting('display_region_b')) {
                         $location_id = $this->getSanParam('facility_district_id');
                     } else {
                         $location_id = $this->getSanParam('facility_province_id');
                     }
                 }
             }
             if (strstr($location_id, '_')) {
                 $parts = explode('_', $location_id);
                 $location_id = $parts[count($parts) - 1];
             }
         }
//.........这里部分代码省略.........
开发者ID:falafflepotatoe,项目名称:trainsmart-code,代码行数:101,代码来源:PsfacilityController.php


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