public function validateAttribute($model, $attribute)
    {
        if ($this->maxFiles != 1 || $this->minFiles > 1) {
            $rawFiles = $model->$attribute;
            if (!is_array($rawFiles)) {
                $this->addError($model, $attribute, $this->uploadRequired);

                return;
            }

            $files = $this->filterFiles($rawFiles);
            $model->$attribute = $files;

            if (empty($files)) {
                $this->addError($model, $attribute, $this->uploadRequired);

                return;
            }

            $filesCount = count($files);
            if ($this->maxFiles && $filesCount > $this->maxFiles) {
                $this->addError($model, $attribute, $this->tooMany, ['limit' => $this->maxFiles]);
            }
            
            if ($this->minFiles && $this->minFiles > $filesCount) {
                $this->addError($model, $attribute, $this->tooFew, ['limit' => $this->minFiles]);
            }

            foreach ($files as $file) {
                $result = $this->validateValue($file);
                if (!empty($result)) {
                    $this->addError($model, $attribute, $result[0], $result[1]);
                }
            }
        } else {
            $result = $this->validateValue($model->$attribute);
            if (!empty($result)) {
                $this->addError($model, $attribute, $result[0], $result[1]);
            }
        }
    }
public function validateAttribute($model, $attribute)
    {
        if ($this->maxFiles != 1 || $this->minFiles > 1) {
            $rawFiles = $model->$attribute;
            if (!is_array($rawFiles)) {
                $this->addError($model, $attribute, $this->uploadRequired);

                return;
            }

            $files = $this->filterFiles($rawFiles);
            $model->$attribute = $files;

            if (empty($files)) {
                $this->addError($model, $attribute, $this->uploadRequired);

                return;
            }

            $filesCount = count($files);
            if ($this->maxFiles && $filesCount > $this->maxFiles) {
                $this->addError($model, $attribute, $this->tooMany, ['limit' => $this->maxFiles]);
            }
            
            if ($this->minFiles && $this->minFiles > $filesCount) {
                $this->addError($model, $attribute, $this->tooFew, ['limit' => $this->minFiles]);
            }

            foreach ($files as $file) {
                $result = $this->validateValue($file);
                if (!empty($result)) {
                    $this->addError($model, $attribute, $result[0], $result[1]);
                }
            }
        } else {
            $result = $this->validateValue($model->$attribute);
            if (!empty($result)) {
                $this->addError($model, $attribute, $result[0], $result[1]);
            }
        }
    }
{@inheritdoc}