本文整理匯總了PHP中Nette\Utils\Validators::isNumeric方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validators::isNumeric方法的具體用法?PHP Validators::isNumeric怎麽用?PHP Validators::isNumeric使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Nette\Utils\Validators
的用法示例。
在下文中一共展示了Validators::isNumeric方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateFloat
/**
* Is a control's value float number?
* @return bool
*/
public static function validateFloat(IControl $control)
{
$value = str_replace(array(' ', ','), array('', '.'), $control->getValue());
if (Validators::isNumeric($value)) {
$control->setValue((double) $value);
return TRUE;
}
return FALSE;
}
示例2: checkQuality
/**
* Check value of quality
*
* @param int|string $quality
* @param string $type
*/
private function checkQuality($quality)
{
// quality must be number or percent
if (Validators::is($quality, 'string') && !Validators::isNumeric($quality)) {
$msg = sprintf('Quality has unexpected format, "%s" given.', $quality);
throw new InvalidArgumentException($msg);
}
// quality cannot be negative number
if ((int) $quality < 0) {
$msg = sprintf('Quality must be greater than 0, "%s" given.', $quality);
throw new InvalidArgumentException($msg);
}
}
示例3: validateFloat
/**
* Is a control's value float number?
* @return bool
* @internal
*/
public static function validateFloat(TextBase $control)
{
$value = self::filterFloat($control->getValue());
if (Validators::isNumeric($value)) {
$control->setValue((double) $value);
return TRUE;
}
return FALSE;
}
示例4: validateFloat
/**
* Is a control's value float number?
* @return bool
* @internal
*/
public static function validateFloat(TextBase $control)
{
return Validators::isNumeric(static::filterFloat($control->getValue()));
}
示例5: parseNumericValue
/**
* Convert string -> int, string -> float because of textual x-www-form-data
* @param mixed $value
* @return mixed
*/
protected function parseNumericValue($value)
{
if (Validators::isNumericInt($value)) {
return (int) $value;
}
if (Validators::isNumeric($value)) {
return (double) $value;
}
return $value;
}