code: 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;
      }
docs: Validate a to-many relation.
  
  @param array $value
  @param string|null $field
  the relationship field name.
  @return bool