/var/www/vhosts/nabawater/vendor/yiisoft/yii2/validators
NameSizeModeActions
BooleanValidator.php30150644editdlrm
CompareValidator.php106530644editdlrm
DateValidator.php191390644editdlrm
DefaultValueValidator.php15220644editdlrm
EachValidator.php64190644editdlrm
EmailValidator.php58210644editdlrm
ExistValidator.php125310644editdlrm
FileValidator.php196700644editdlrm
FilterValidator.php28540644editdlrm
ImageValidator.php74340644editdlrm
InlineValidator.php28530644editdlrm
IpValidator.php197840644editdlrm
NumberValidator.php61460644editdlrm
PunycodeAsset.php5150644editdlrm
RangeValidator.php39240644editdlrm
RegularExpressionValidator.php25220644editdlrm
RequiredValidator.php39340644editdlrm
SafeValidator.php16510644editdlrm
StringValidator.php67220644editdlrm
UniqueValidator.php135250644editdlrm
UrlValidator.php52920644editdlrm
ValidationAsset.php5470644editdlrm
Validator.php201990644editdlrm
Edit: /var/www/vhosts/nabawater/vendor/yiisoft/yii2/validators/RangeValidator.php (3924B)
* @since 2.0 */ class RangeValidator extends Validator { /** * @var array|\Traversable|\Closure a list of valid values that the attribute value should be among or an anonymous function that returns * such a list. The signature of the anonymous function should be as follows, * * ```php * function($model, $attribute) { * // compute range * return $range; * } * ``` */ public $range; /** * @var bool whether the comparison is strict (both type and value must be the same) */ public $strict = false; /** * @var bool whether to invert the validation logic. Defaults to false. If set to true, * the attribute value should NOT be among the list of values defined via [[range]]. */ public $not = false; /** * @var bool whether to allow array type attribute. */ public $allowArray = false; /** * {@inheritdoc} */ public function init() { parent::init(); if (!is_array($this->range) && !($this->range instanceof \Closure) && !($this->range instanceof \Traversable) ) { throw new InvalidConfigException('The "range" property must be set.'); } if ($this->message === null) { $this->message = Yii::t('yii', '{attribute} is invalid.'); } } /** * {@inheritdoc} */ protected function validateValue($value) { $in = false; if ($this->allowArray && ($value instanceof \Traversable || is_array($value)) && ArrayHelper::isSubset($value, $this->range, $this->strict) ) { $in = true; } if (!$in && ArrayHelper::isIn($value, $this->range, $this->strict)) { $in = true; } return $this->not !== $in ? null : [$this->message, []]; } /** * {@inheritdoc} */ public function validateAttribute($model, $attribute) { if ($this->range instanceof \Closure) { $this->range = call_user_func($this->range, $model, $attribute); } parent::validateAttribute($model, $attribute); } /** * {@inheritdoc} */ public function clientValidateAttribute($model, $attribute, $view) { if ($this->range instanceof \Closure) { $this->range = call_user_func($this->range, $model, $attribute); } ValidationAsset::register($view); $options = $this->getClientOptions($model, $attribute); return 'yii.validation.range(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');'; } /** * {@inheritdoc} */ public function getClientOptions($model, $attribute) { $range = []; foreach ($this->range as $value) { $range[] = (string) $value; } $options = [ 'range' => $range, 'not' => $this->not, 'message' => $this->formatMessage($this->message, [ 'attribute' => $model->getAttributeLabel($attribute), ]), ]; if ($this->skipOnEmpty) { $options['skipOnEmpty'] = 1; } if ($this->allowArray) { $options['allowArray'] = 1; } return $options; } }