code: private function checkTargetRelationExistence($model, $attribute)
      {
          $exists = false;
          /** @var ActiveQuery $relationQuery */
          $relationQuery = $model->{'get' . ucfirst($this->targetRelation)}();
  
          if ($this->filter instanceof \Closure) {
              call_user_func($this->filter, $relationQuery);
          } elseif ($this->filter !== null) {
              $relationQuery->andWhere($this->filter);
          }
  
          if ($this->forceMasterDb && method_exists($model::getDb(), 'useMaster')) {
              $model::getDb()->useMaster(function() use ($relationQuery, &$exists) {
                  $exists = $relationQuery->exists();
              });
          } else {
              $exists = $relationQuery->exists();
          }
  
  
          if (!$exists) {
              $this->addError($model, $attribute, $this->message);
          }
      }
docs: Validates existence of the current attribute based on relation name
  @param \yii\db\ActiveRecord $model the data model to be validated
  @param string $attribute the name of the attribute to be validated.