yii\validators\Validator::validateAttributes PHP Method

validateAttributes() public method

Validates the specified object.
public validateAttributes ( Model $model, array | null $attributes = null )
$model yii\base\Model the data model being validated
$attributes array | null the list of attributes to be validated. Note that if an attribute is not associated with the validator, or is is prefixed with `!` char - it will be ignored. If this parameter is null, every attribute listed in [[attributes]] will be validated.
    public function validateAttributes($model, $attributes = null)
    {
        if (is_array($attributes)) {
            $newAttributes = [];
            foreach ($attributes as $attribute) {
                if (in_array($attribute, $this->attributes) || in_array('!' . $attribute, $this->attributes)) {
                    $newAttributes[] = $attribute;
                }
            }
            $attributes = $newAttributes;
        } else {
            $attributes = [];
            foreach ($this->attributes as $attribute) {
                $attributes[] = $attribute[0] === '!' ? substr($attribute, 1) : $attribute;
            }
        }
        foreach ($attributes as $attribute) {
            $skip = $this->skipOnError && $model->hasErrors($attribute) || $this->skipOnEmpty && $this->isEmpty($model->{$attribute});
            if (!$skip) {
                if ($this->when === null || call_user_func($this->when, $model, $attribute)) {
                    $this->validateAttribute($model, $attribute);
                }
            }
        }
    }