Skip to content

Commit

Permalink
Reject duplicate ROR IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
matyasselmeci committed Jan 24, 2024
1 parent 9bff667 commit cd07956
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/webapp/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ def validate_institution_ids(institution_ids: List) -> List[str]:
errors = []
institution_name_fields_set = set()
institution_id_fields_set = set()
institution_ror_id_fields_set = set()
for ii in institution_ids:
name = ii.get("name", None)
id_ = ii.get("id", None)
ror_id = ii.get("ror_id", None)
if not name:
errors.append("Missing 'name' in entry %r" % ii)
continue
Expand All @@ -72,6 +74,11 @@ def validate_institution_ids(institution_ids: List) -> List[str]:
if id_ in institution_id_fields_set:
errors.append("Duplicate 'id' %s in entry %r" % (id_, ii))
continue
if ror_id: # ROR is optional but must be unique if specified
if ror_id in institution_ror_id_fields:
errors.append("Duplicate 'ror_id' %s in entry %r" % (ror_id, ii))
continue
institution_ror_fields_set.add(ror_id)
institution_name_fields_set.add(name)
institution_id_fields_set.add(id_)
return errors
Expand Down

0 comments on commit cd07956

Please sign in to comment.