src/Validators/ExistValidator.php
private function checkTargetAttributeExistence($model, $attribute)
    {
        $targetAttribute = $this->targetAttribute === null ? $attribute : $this->targetAttribute;
        $params = $this->prepareConditions($targetAttribute, $model, $attribute);
        $conditions = [$this->targetAttributeJunction == 'or' ? 'or' : 'and'];

        if (!$this->allowArray) {
            foreach ($params as $key => $value) {
                if (is_array($value)) {
                    $this->addError($model, $attribute, Reaction::t('rct', '{attribute} is invalid.'));

                    return null;
                }
                $conditions[] = [$key => $value];
            }
        } else {
            $conditions[] = $params;
        }

        $targetClass = $this->targetClass === null ? get_class($model) : $this->targetClass;
        $query = $this->createQuery($targetClass, $conditions);

        return $this->valueExists($query, $model->$attribute)
            ->then(null, function() use (&$model, $attribute) {
                $this->addError($model, $attribute, $this->message);
                return null;
            });
    }
private function checkTargetAttributeExistence($model, $attribute)
    {
        $targetAttribute = $this->targetAttribute === null ? $attribute : $this->targetAttribute;
        $params = $this->prepareConditions($targetAttribute, $model, $attribute);
        $conditions = [$this->targetAttributeJunction == 'or' ? 'or' : 'and'];

        if (!$this->allowArray) {
            foreach ($params as $key => $value) {
                if (is_array($value)) {
                    $this->addError($model, $attribute, Reaction::t('rct', '{attribute} is invalid.'));

                    return null;
                }
                $conditions[] = [$key => $value];
            }
        } else {
            $conditions[] = $params;
        }

        $targetClass = $this->targetClass === null ? get_class($model) : $this->targetClass;
        $query = $this->createQuery($targetClass, $conditions);

        return $this->valueExists($query, $model->$attribute)
            ->then(null, function() use (&$model, $attribute) {
                $this->addError($model, $attribute, $this->message);
                return null;
            });
    }
Validates existence of the current attribute based on targetAttribute
@param \Reaction\Base\Model $model the data model to be validated
@param string $attribute the name of the attribute to be validated.