src/Validation/Spec/AbstractValidator.php
protected function validateIdentifier($value, string $path, ?int $index = null): bool
    {
        $member = is_int($index) ? (string) $index : 'data';

        if (!is_object($value)) {
            $this->memberNotObject($path, $member);
            return false;
        }

        $dataPath = sprintf('%s/%s', rtrim($path, '/'), $member);
        $valid = true;

        if (!property_exists($value, 'type')) {
            $this->memberRequired($dataPath, 'type');
            $valid = false;
        } else if (!$this->validateTypeMember($value->type, $dataPath)) {
            $valid = false;
        }

        if (!property_exists($value, 'id')) {
            $this->memberRequired($dataPath, 'id');
            $valid = false;
        } else if (!$this->validateIdMember($value->id, $dataPath)) {
            $valid = false;
        }

        /** If it has attributes or relationships, it is a resource object not a resource identifier */
        if (property_exists($value, 'attributes') || property_exists($value, 'relationships')) {
            $this->memberNotIdentifier($path, $member);
            $valid = false;
        }

        return $valid;
    }
protected function validateIdentifier($value, string $path, ?int $index = null): bool
    {
        $member = is_int($index) ? (string) $index : 'data';

        if (!is_object($value)) {
            $this->memberNotObject($path, $member);
            return false;
        }

        $dataPath = sprintf('%s/%s', rtrim($path, '/'), $member);
        $valid = true;

        if (!property_exists($value, 'type')) {
            $this->memberRequired($dataPath, 'type');
            $valid = false;
        } else if (!$this->validateTypeMember($value->type, $dataPath)) {
            $valid = false;
        }

        if (!property_exists($value, 'id')) {
            $this->memberRequired($dataPath, 'id');
            $valid = false;
        } else if (!$this->validateIdMember($value->id, $dataPath)) {
            $valid = false;
        }

        /** If it has attributes or relationships, it is a resource object not a resource identifier */
        if (property_exists($value, 'attributes') || property_exists($value, 'relationships')) {
            $this->memberNotIdentifier($path, $member);
            $valid = false;
        }

        return $valid;
    }
Validate an identifier object.

@param mixed $value
@param string $path
the path to the data member in which the identifier is contained.
@param int|null $index
the index for the identifier, if in a collection.
@return bool