code: protected function validateRelationship(RelationshipInterface $relationship, $key = null)
      {
          if (!$relationship->has(RelationshipInterface::DATA)) {
              $this->addError($this->errorFactory->memberRequired(
                  RelationshipInterface::DATA,
                  $key ? P::relationship($key) : P::data()
              ));
              return false;
          }
  
          if (!$relationship->isHasOne() && !$relationship->isHasMany()) {
              $this->addError($this->errorFactory->memberRelationshipExpected(
                  RelationshipInterface::DATA,
                  $key ? P::relationship($key) : P::data()
              ));
              return false;
          }
  
          if (!$this->validateEmpty($relationship, $key)) {
              return false;
          }
  
          return true;
      }
docs: Validate that a data member exists and it is either a has-one or a has-many relationship.
  
  @param RelationshipInterface $relationship
  @param string|null $key
  @return bool