本文整理汇总了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');
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例8: isLengthBetween
public static function isLengthBetween($string, $minLength, $maxLength)
{
return Validators::isInRange(Strings::length($string), array($minLength, $maxLength));
}
示例9:
Validators::isNumeric(static::filterFloat($control->getValue()));}static
function
validateRange(TextBase$control,$range){return
Validators::isInRange($control->getValue(),$range);}static
示例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;
}
示例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);
}
示例12: validateLength
public static function validateLength(IControl $control, $range)
{
if (!is_array($range)) {
$range = array($range, $range);
}
return Validators::isInRange(count($control->getValue()), $range);
}