src/Validators/ExistValidator.php
private function checkTargetRelationExistence($model, $attribute)
    {
        /** @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);
        }

        return $relationQuery->exists()
            ->then(null, function() use ($model, $attribute) {
                $this->addError($model, $attribute, $this->message);
                return null;
            });
    }
private function checkTargetRelationExistence($model, $attribute)
    {
        /** @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);
        }

        return $relationQuery->exists()
            ->then(null, function() use ($model, $attribute) {
                $this->addError($model, $attribute, $this->message);
                return null;
            });
    }
Validates existence of the current attribute based on relation name
@param \Reaction\Db\Orm\ActiveRecord $model the data model to be validated
@param string                        $attribute the name of the attribute to be validated.
@return ExtendedPromiseInterface