Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -16,6 +16,15 @@ class Between extends AbstractValidator
{
const NOT_BETWEEN = 'notBetween';
const NOT_BETWEEN_STRICT = 'notBetweenStrict';
const VALUE_NOT_NUMERIC = 'valueNotNumeric';
const VALUE_NOT_STRING = 'valueNotString';
/**
* Retain if min and max are numeric values. Allow to not compare string and numeric types
*
* @var boolean
*/
private $numeric;
/**
* Validation failure message template definitions
@@ -24,7 +33,10 @@ class Between extends AbstractValidator
*/
protected $messageTemplates = [
self::NOT_BETWEEN => "The input is not between '%min%' and '%max%', inclusively",
self::NOT_BETWEEN_STRICT => "The input is not strictly between '%min%' and '%max%'"
self::NOT_BETWEEN_STRICT => "The input is not strictly between '%min%' and '%max%'",
self::VALUE_NOT_NUMERIC => "The min ('%min%') and max ('%max%') values are numeric, but the input is not",
self::VALUE_NOT_STRING => "The min ('%min%') and max ('%max%') values are non-numeric strings, "
. "but the input is not a string",
];
/**
@@ -64,24 +76,36 @@ class Between extends AbstractValidator
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (!is_array($options)) {
if (! is_array($options)) {
$options = func_get_args();
$temp['min'] = array_shift($options);
if (!empty($options)) {
if (! empty($options)) {
$temp['max'] = array_shift($options);
}
if (!empty($options)) {
if (! empty($options)) {
$temp['inclusive'] = array_shift($options);
}
$options = $temp;
}
if (count($options) !== 2
&& (!array_key_exists('min', $options) || !array_key_exists('max', $options))
if (! array_key_exists('min', $options) || ! array_key_exists('max', $options)) {
throw new Exception\InvalidArgumentException("Missing option: 'min' and 'max' have to be given");
}
if ((isset($options['min']) && is_numeric($options['min']))
&& (isset($options['max']) && is_numeric($options['max']))
) {
throw new Exception\InvalidArgumentException("Missing option. 'min' and 'max' have to be given");
$this->numeric = true;
} elseif ((isset($options['min']) && is_string($options['min']))
&& (isset($options['max']) && is_string($options['max']))
) {
$this->numeric = false;
} else {
throw new Exception\InvalidArgumentException(
"Invalid options: 'min' and 'max' should be of the same scalar type"
);
}
parent::__construct($options);
@@ -164,6 +188,15 @@ class Between extends AbstractValidator
{
$this->setValue($value);
if ($this->numeric && ! is_numeric($value)) {
$this->error(self::VALUE_NOT_NUMERIC);
return false;
}
if (! $this->numeric && ! is_string($value)) {
$this->error(self::VALUE_NOT_STRING);
return false;
}
if ($this->getInclusive()) {
if ($this->getMin() > $value || $value > $this->getMax()) {
$this->error(self::NOT_BETWEEN);