當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validators::isInRange方法代碼示例

本文整理匯總了PHP中Nette\Utils\Validators::isInRange方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validators::isInRange方法的具體用法?PHP Validators::isInRange怎麽用?PHP Validators::isInRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Utils\Validators的用法示例。


在下文中一共展示了Validators::isInRange方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getMessage

 /**
  * Get status code from response
  * @param string $response Response
  * @return string Status message
  */
 public function getMessage($response)
 {
     if ($response == 'OK') {
         return 'OK';
     } else {
         if (Strings::startsWith($response, 'ERROR ') && Validators::isInRange(explode(' ', $response)[1], [1, 18])) {
             return explode(';', $response)[1];
         } else {
             throw new \InvalidArgumentException('Invalid response');
         }
     }
 }
開發者ID:roman3349,項目名稱:iqrf-cloud-nette,代碼行數:17,代碼來源:Status.php

示例2: getSettings

 /**
  * @throws ImageStorageException
  * @return array
  */
 public function getSettings()
 {
     if (!$this->settings) {
         $config = $this->validateConfig($this->defaults);
         $config['wwwDir'] = Nette\DI\Helpers::expand($config['wwwDir'], $this->getContainerBuilder()->parameters);
         // Validation
         $quality = $config['quality'];
         if (!is_int($quality) || !Validators::isInRange($quality, [0, 100])) {
             throw new ImageStorageException('Quality must be an integer from 0 to 100.');
         }
         foreach ($config['events'] as $name => &$array) {
             Validators::assert($array, 'array');
         }
         foreach ($config['helpers'] as $name => $class) {
             if (!class_exists($class) || $class instanceof IHelper) {
                 throw new ImageStorageException("Helper {$name} must be instance of " . IHelper::class);
             }
         }
         $this->settings = $config;
     }
     return $this->settings;
 }
開發者ID:webchemistry,項目名稱:images,代碼行數:26,代碼來源:ImagesExtension.php

示例3: validateLength

 /**
  * Count/length validator. Range is array, min and max length pair.
  * @return bool
  */
 public static function validateLength(IControl $control, $range)
 {
     if (!is_array($range)) {
         $range = array($range, $range);
     }
     $value = $control->getValue();
     return Validators::isInRange(is_array($value) ? count($value) : Strings::length($value), $range);
 }
開發者ID:rostenkowski,項目名稱:nette,代碼行數:12,代碼來源:Validator.php

示例4: validateRange

 /**
  * Rangle validator: is a control's value number in specified range?
  * @param  TextBase
  * @param  array  min and max value pair
  * @return bool
  */
 public static function validateRange(TextBase $control, $range)
 {
     return Validators::isInRange($control->getValue(), $range);
 }
開發者ID:ppwalks33,項目名稱:cleansure,代碼行數:10,代碼來源:TextBase.php

示例5: validateRange

 /**
  * Rangle validator: is a control's value number in specified range?
  * @param  Nette\Forms\IControl
  * @param  array  min and max value pair
  * @return bool
  */
 public static function validateRange(IControl $control, $range)
 {
     return Nette\Utils\Validators::isInRange($control->getValue(), $range);
 }
開發者ID:radeksimko,項目名稱:nette,代碼行數:10,代碼來源:BaseControl.php

示例6: validateRange

 /**
  * @param UploadControl $control
  * @param $range
  * @return bool
  */
 public static function validateRange(UploadControl $control, $range)
 {
     $files = count($control->getValue());
     return Validators::isInRange($files, $range);
 }
開發者ID:f3l1x,項目名稱:nette-plugins,代碼行數:10,代碼來源:MultiUploadControl.php

示例7: isDateInRange

 /**
  * kontrola datumu v rozsahu
  * @param  [type]  $from  od
  * @param  [type]  $to    do
  * @param  [type]  $value now
  * @return boolean        [description]
  */
 public static function isDateInRange($from, $to, $value = null)
 {
     $d1 = new \DateTime($from);
     $d2 = new \DateTime($to);
     $now = new \DateTime($value);
     if ($from && $to) {
         return \Nette\Utils\Validators::isInRange($now, array($d1, $d2));
     }
     return false;
 }
開發者ID:geniv,項目名稱:goodflow,代碼行數:17,代碼來源:Core.php

示例8: isLengthBetween

 public static function isLengthBetween($string, $minLength, $maxLength)
 {
     return Validators::isInRange(Strings::length($string), array($minLength, $maxLength));
 }
開發者ID:jaromir92,項目名稱:Sportwin,代碼行數:4,代碼來源:StringUtils.php

示例9:

Validators::isNumeric(static::filterFloat($control->getValue()));}static
function
validateRange(TextBase$control,$range){return
Validators::isInRange($control->getValue(),$range);}static
開發者ID:JanTvrdik,項目名稱:NetteExtras,代碼行數:4,代碼來源:loader.php

示例10: setQuality

 /**
  * @param int $quality
  * @return PropertyAccess
  * @throws WebChemistry\Images\ImageStorageException
  */
 public function setQuality($quality)
 {
     if (!is_int($quality)) {
         throw new WebChemistry\Images\ImageStorageException(printf('Parameter quality must be integer, %s given.', gettype($quality)));
     } else {
         if (!Nette\Utils\Validators::isInRange($quality, [0, 100])) {
             throw new WebChemistry\Images\ImageStorageException('Quality must be value in range 0 - 100.');
         }
     }
     $this->quality = $quality;
     return $this;
 }
開發者ID:webchemistry,項目名稱:images,代碼行數:17,代碼來源:PropertyAccess.php

示例11: validateLength

 /**
  * Length validator: is control's value length in range?
  * @param  TextBase
  * @param  array  min and max length pair
  * @return bool
  */
 public static function validateLength(TextBase $control, $range)
 {
     if (!is_array($range)) {
         $range = array($range, $range);
     }
     return Validators::isInRange(Strings::length($control->getValue()), $range);
 }
開發者ID:radeksimko,項目名稱:nette,代碼行數:13,代碼來源:TextBase.php

示例12: validateLength

 public static function validateLength(IControl $control, $range)
 {
     if (!is_array($range)) {
         $range = array($range, $range);
     }
     return Validators::isInRange(count($control->getValue()), $range);
 }
開發者ID:pavelkouril,項目名稱:nextras-forms,代碼行數:7,代碼來源:MultiOptionList.php


注:本文中的Nette\Utils\Validators::isInRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。