From cb69fa5b7a744ea807af751c124459355cea1bd9 Mon Sep 17 00:00:00 2001 From: Tom Morrell Date: Mon, 2 Dec 2024 15:11:07 -0800 Subject: [PATCH] Remove identifiers requirement --- caltechdata_api/customize_schema.py | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/caltechdata_api/customize_schema.py b/caltechdata_api/customize_schema.py index 8f0fc19..eb3a351 100644 --- a/caltechdata_api/customize_schema.py +++ b/caltechdata_api/customize_schema.py @@ -416,8 +416,12 @@ def validate_metadata(json_record): # Check for 'identifiers' if "identifiers" in json_record: - if not isinstance(json_record["identifiers"], list): - errors.append("'identifiers' should be a list.") + + if ( + not isinstance(json_record["identifiers"], list) + or len(json_record["identifiers"]) == 0 + ): + errors.append("'identifiers' should be a non-empty list.") else: for identifier in json_record["identifiers"]: if ( @@ -490,25 +494,6 @@ def validate_metadata(json_record): ): errors.append("Each 'date' must have 'date' and 'dateType'.") - # Check for 'identifiers' - if "identifiers" not in json_record: - errors.append("'identifiers' field is missing.") - elif ( - not isinstance(json_record["identifiers"], list) - or len(json_record["identifiers"]) == 0 - ): - errors.append("'identifiers' should be a non-empty list.") - else: - for identifier in json_record["identifiers"]: - if ( - not isinstance(identifier, dict) - or "identifier" not in identifier - or "identifierType" not in identifier - ): - errors.append( - "Each 'identifier' must have 'identifier' and 'identifierType'." - ) - # Check for 'creators' if "creators" not in json_record: errors.append("'creators' field is missing.")