Skip to content

Commit

Permalink
Merge pull request #493 from hubmapconsortium/kburke/collectionAsEnti…
Browse files Browse the repository at this point in the history
…tyPatchFromSN

Small change to keep code aligned with SenNet, which logs and returns…
  • Loading branch information
yuanzhou authored Jun 20, 2023
2 parents 7ab8db0 + 4a065eb commit 3e162d9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/schema/schema_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,19 @@ def verify_DOI_pair(property_key, normalized_entity_type, request, existing_data
# Since both DOI parameters are present, make sure neither is the empty string
if new_data_dict['doi_url'] == '' or new_data_dict['registered_doi'] == '':
raise ValueError( f"The properties 'doi_url' and 'registered_doi' cannot be empty, when specified.")

# Check if doi_url matches registered_doi with the expected prefix
if new_data_dict['doi_url'] != SchemaConstants.DOI_BASE_URL + new_data_dict['registered_doi']:
try:
expected_doi_url = SchemaConstants.DOI_BASE_URL + new_data_dict['registered_doi']
except Exception as e:
# If SchemaConstants.DOI_BASE_URL is not set, or there is some other
# problem, give up and fail this validation.
logger.error(f"During verify_DOI_pair schema validator, unexpected exception e={str(e)}")
raise ValueError(f"An unexpected error occurred during evaluation of DOI parameters. See logs.")
if expected_doi_url and new_data_dict['doi_url'] != expected_doi_url:
raise ValueError( f"The 'doi_url' property should match the 'registered_doi' property, after"
f" the prefix {SchemaConstants.DOI_BASE_URL}.")

"""
Validate every entity in a list is of entity_type accepted
Expand Down

0 comments on commit 3e162d9

Please sign in to comment.