src/Validation/Spec/AbstractValidator.php
protected function validateToMany(array $value, ?string $field = null): bool
    {
        $path = $field ? "/data/relationships/{$field}/data" : "/data";
        $valid = true;

        foreach ($value as $index => $item) {
            if (!$this->validateIdentifier($item, $path, $index)) {
                $valid = false;
                continue;
            }

            if ($this->isNotFound($item->type, $item->id)) {
                $this->resourceDoesNotExist("{$path}/{$index}");
                $valid = false;
            }
        }

        return $valid;
    }
protected function validateToMany(array $value, ?string $field = null): bool
    {
        $path = $field ? "/data/relationships/{$field}/data" : "/data";
        $valid = true;

        foreach ($value as $index => $item) {
            if (!$this->validateIdentifier($item, $path, $index)) {
                $valid = false;
                continue;
            }

            if ($this->isNotFound($item->type, $item->id)) {
                $this->resourceDoesNotExist("{$path}/{$index}");
                $valid = false;
            }
        }

        return $valid;
    }
Validate a to-many relation.

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