/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/RequiredValidator.php (3934B)
* @since 2.0 */ class RequiredValidator extends Validator { /** * @var bool whether to skip this validator if the value being validated is empty. */ public $skipOnEmpty = false; /** * @var mixed the desired value that the attribute must have. * If this is null, the validator will validate that the specified attribute is not empty. * If this is set as a value that is not null, the validator will validate that * the attribute has a value that is the same as this property value. * Defaults to null. * @see strict */ public $requiredValue; /** * @var bool whether the comparison between the attribute value and [[requiredValue]] is strict. * When this is true, both the values and types must match. * Defaults to false, meaning only the values need to match. * Note that when [[requiredValue]] is null, if this property is true, the validator will check * if the attribute value is null; If this property is false, the validator will call [[isEmpty]] * to check if the attribute value is empty. */ public $strict = false; /** * @var string the user-defined error message. It may contain the following placeholders which * will be replaced accordingly by the validator: * * - `{attribute}`: the label of the attribute being validated * - `{value}`: the value of the attribute being validated * - `{requiredValue}`: the value of [[requiredValue]] */ public $message; /** * {@inheritdoc} */ public function init() { parent::init(); if ($this->message === null) { $this->message = $this->requiredValue === null ? Yii::t('yii', '{attribute} cannot be blank.') : Yii::t('yii', '{attribute} must be "{requiredValue}".'); } } /** * {@inheritdoc} */ protected function validateValue($value) { if ($this->requiredValue === null) { if ($this->strict && $value !== null || !$this->strict && !$this->isEmpty(is_string($value) ? trim($value) : $value)) { return null; } } elseif (!$this->strict && $value == $this->requiredValue || $this->strict && $value === $this->requiredValue) { return null; } if ($this->requiredValue === null) { return [$this->message, []]; } return [$this->message, [ 'requiredValue' => $this->requiredValue, ]]; } /** * {@inheritdoc} */ public function clientValidateAttribute($model, $attribute, $view) { ValidationAsset::register($view); $options = $this->getClientOptions($model, $attribute); return 'yii.validation.required(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');'; } /** * {@inheritdoc} */ public function getClientOptions($model, $attribute) { $options = []; if ($this->requiredValue !== null) { $options['message'] = $this->formatMessage($this->message, [ 'requiredValue' => $this->requiredValue, ]); $options['requiredValue'] = $this->requiredValue; } else { $options['message'] = $this->message; } if ($this->strict) { $options['strict'] = 1; } $options['message'] = $this->formatMessage($options['message'], [ 'attribute' => $model->getAttributeLabel($attribute), ]); return $options; } }