code: private static void validateMappedBy(Attribute attr, Attribute mappedByAttr) {
      if (mappedByAttr != null) {
        if (!isSingleReferenceType(mappedByAttr)) {
          throw new MolgenisDataException(
              format(
                  "Invalid mappedBy attribute [%s] data type [%s].",
                  mappedByAttr.getName(), mappedByAttr.getDataType()));
        }
  
        Attribute refAttr = attr.getRefEntity().getAttribute(mappedByAttr.getName());
        if (refAttr == null) {
          throw new MolgenisDataException(
              format(
                  "mappedBy attribute [%s] is not part of entity [%s].",
                  mappedByAttr.getName(), attr.getRefEntity().getId()));
        }
      }
    }
docs: Validate whether the mappedBy attribute is part of the referenced entity.
  
  @param attr attribute
  @param mappedByAttr mappedBy attribute
  @throws MolgenisDataException if mappedBy is an attribute that is not part of the referenced
  entity