code: protected function validateRelationship($relation, ?string $field = null): bool
      {
          $path = $field ? '/data/relationships' : '/';
          $member = $field ?: 'data';
  
          if (!is_object($relation)) {
              $this->memberNotObject($path, $member);
              return false;
          }
  
          $path = $field ? "{$path}/{$field}" : $path;
  
          if (!property_exists($relation, 'data')) {
              $this->memberRequired($path, 'data');
              return false;
          }
  
          $data = $relation->data;
  
          if (is_array($data)) {
              return $this->validateToMany($data, $field);
          }
  
          return $this->validateToOne($data, $field);
      }
docs: Validate a resource relationship.
  
  @param mixed $relation
  @param string|null $field
  @return bool