code: protected function validateSlug($slug)
      {
          /* @var $validator UniqueValidator */
          /* @var $model BaseActiveRecord */
          $validator = Yii::createObject(array_merge(
              [
                  'class' => UniqueValidator::className(),
              ],
              $this->uniqueValidator
          ));
  
          $model = clone $this->owner;
          $model->clearErrors();
          $model->{$this->slugAttribute} = $slug;
  
          $validator->validateAttribute($model, $this->slugAttribute);
          return !$model->hasErrors();
      }
docs: Checks if given slug value is unique.
  @param string $slug slug value
  @return bool whether slug is unique.