src/Validation/Spec/AbstractValidator.php
protected function validateToOne($value, ?string $field = null): bool
    {
        if (is_null($value)) {
            return true;
        }

        $dataPath = $field ? "/data/relationships/{$field}" : "/";
        $identifierPath = $field ? "/data/relationships/{$field}" : "/data";

        if (!$this->validateIdentifier($value, $dataPath)) {
            return false;
        }

        if (!$this->store->exists(new ResourceIdentifier($value))) {
            $this->resourceDoesNotExist($identifierPath);
            return false;
        }

        return true;
    }
protected function validateToOne($value, ?string $field = null): bool
    {
        if (is_null($value)) {
            return true;
        }

        $dataPath = $field ? "/data/relationships/{$field}" : "/";
        $identifierPath = $field ? "/data/relationships/{$field}" : "/data";

        if (!$this->validateIdentifier($value, $dataPath)) {
            return false;
        }

        if (!$this->store->exists(new ResourceIdentifier($value))) {
            $this->resourceDoesNotExist($identifierPath);
            return false;
        }

        return true;
    }
Validate a to-one relation.

@param mixed $value
@param string|null $field
the relationship field name.
@return bool