protected function validateRelationships(): bool
    {
        if (!$this->dataHas('relationships')) {
            return true;
        }

        $relationships = $this->dataGet('relationships');

        if (!is_object($relationships)) {
            $this->memberNotObject('/data', 'relationships');
            return false;
        }

        $disallowed = collect(['type', 'id'])->filter(function ($field) use ($relationships) {
            return property_exists($relationships, $field);
        });

        $valid = $disallowed->isEmpty();
        $this->memberFieldsNotAllowed('/data', 'relationships', $disallowed);

        foreach ($relationships as $field => $relation) {
            if (!$this->validateRelationship($relation, $field)) {
                $valid = false;
            }
        }

        return $valid;
    }