/**
  * @param ResourceIdentifierInterface $identifier
  * @param string|null $key
  * @return bool
  */
 protected function validateIdentifier(ResourceIdentifierInterface $identifier, $key = null)
 {
     $valid = true;
     /** Must have a type */
     if (!$identifier->hasType()) {
         $this->addError($this->errorFactory->memberRequired(ResourceIdentifierInterface::TYPE, $key ? P::relationshipData($key) : P::data()));
         $valid = false;
     } elseif (!$this->isSupportedType($identifier->getType())) {
         $this->addError($this->errorFactory->relationshipUnsupportedType($this->expectedTypes, $identifier->getType(), $key));
         $valid = false;
     }
     /** Must have an id */
     if (!$identifier->hasId()) {
         $this->addError($this->errorFactory->memberRequired(ResourceIdentifierInterface::ID, $key ? P::relationshipId($key) : P::data()));
         $valid = false;
     }
     return $valid;
 }