From 03f0d66d39a6b9ad8023bc3145f5e248bb24d39c Mon Sep 17 00:00:00 2001 From: Jan Pospisil Date: Tue, 28 Feb 2017 12:30:57 +0100 Subject: [PATCH] Fix namespace in validators --- src/Parameters.php | 7 +------ src/Validator.php | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Parameters.php b/src/Parameters.php index d708fc3..4993564 100644 --- a/src/Parameters.php +++ b/src/Parameters.php @@ -8,13 +8,8 @@ use Nette\Http\IRequest; use Nette\Http\Request; use Nette\Object; -use Nette\Utils\ArrayHash; -use Nette\Utils\Json; use Nette\Utils\Strings; -use Nette\Utils\Validators; -use RestServer\Exceptions\InvalidParameterException; -use RestServer\Exceptions\MissingRequiredParameterException; -use Tracy\Debugger; + /** * Parameters diff --git a/src/Validator.php b/src/Validator.php index d7b7dce..1ce11ab 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -1,5 +1,9 @@ '.')); + if(!Validators::isNumeric($value)) + throw new InvalidParameterException('Parameter "'.$name.'" must be float.'); + $value = (float) $value; + } elseif($validator == Check::BOOL){ + if(!is_bool($value) && $value != 1 && $value != 0) + throw new InvalidParameterException('Parameter "'.$name.'" must be boolean.'); + $value = (bool) $value; } else {