Skip to content

Commit

Permalink
Merge commit 'b4f8d0a17a1c9a99274d0e250f6179d14a8728a8'
Browse files Browse the repository at this point in the history
  • Loading branch information
swoft-bot committed Nov 21, 2018
2 parents 036d98b + cacd775 commit f9910dc
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/Helper/ValidatorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

use Swoft\Exception\ValidatorException;

/**
* Class ValidatorHelper
*
* @package Swoft\Helper
*/
class ValidatorHelper
{
/**
Expand Down Expand Up @@ -120,15 +115,15 @@ public static function validateNumber(string $name, $value, $min = null, $max =

$value = (int)$value;
if ($min !== null && $value < $min) {
$template = empty($template) ?: $template;
$template = empty($template) ? sprintf('Parameter %s is too short (minimum is %d)', $name, $min): $template;

return self::validateError(sprintf('Parameter %s is too small (minimum is %d)', $name, $min), $throws);
return self::validateError($template, $throws);
}

if ($max !== null && $value > $max) {
$template = empty($template) ?: $template;
$template = empty($template) ? sprintf('Parameter %s is too large (maximum is %d)', $name, $max) : $template;

return self::validateError(sprintf('Parameter %s is too big (maximum is %d)', $name, $max), $throws);
return self::validateError($template, $throws);
}

return (int)$value;
Expand Down Expand Up @@ -177,13 +172,13 @@ public static function validateFloat(

$value = (float)$value;
if ($min !== null && $value < $min) {
$template = empty($template) ? sprintf('Parameter %s is too small (minimum is %d)', $name, $min) : $template;
$template = empty($template) ? sprintf('Parameter %s is too short (minimum is %d)', $name, $min) : $template;

return self::validateError($template, $throws);
}

if ($max !== null && $value > $max) {
$template = empty($template) ? sprintf('Parameter %s is too big (maximum is %d)', $name, $max) : $template;
$template = empty($template) ? sprintf('Parameter %s is too large (maximum is %d)', $name, $max) : $template;

return self::validateError($template, $throws);
}
Expand Down

0 comments on commit f9910dc

Please sign in to comment.