Skip to content

Commit 09cc08f

Browse files
Clarify 'or' requirement in message for subject age + DOB (#411)
* swap and to or in message * fix test * pr suggestions * add parallel date of birth check * changelog * add to DANDI config * remove other function * Update dandi.inspector_config.yaml * Update CHANGELOG.md
1 parent 1cc1119 commit 09cc08f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/nwbinspector/checks/nwbfile_metadata.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,12 @@ def check_doi_publications(nwbfile: NWBFile):
132132
@register_check(importance=Importance.BEST_PRACTICE_SUGGESTION, neurodata_type=Subject)
133133
def check_subject_age(subject: Subject):
134134
"""Check if the Subject age is in ISO 8601 or our extension of it for ranges."""
135-
if subject.age is None:
136-
if subject.date_of_birth is None:
137-
return InspectorMessage(message="Subject is missing age and date_of_birth.")
138-
else:
139-
return
135+
if subject.age is None and subject.date_of_birth is None:
136+
return InspectorMessage(
137+
message="Subject is missing age and date_of_birth. Please specify at least one of these fields."
138+
)
139+
elif subject.age is None and subject.date_of_birth is not None:
140+
return
140141
if re.fullmatch(pattern=duration_regex, string=subject.age):
141142
return
142143

tests/unit_tests/test_nwbfile_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def test_pass_check_subject_age_with_dob():
336336
def test_check_subject_age_missing():
337337
subject = Subject(subject_id="001")
338338
assert check_subject_age(subject) == InspectorMessage(
339-
message="Subject is missing age and date_of_birth.",
339+
message="Subject is missing age and date_of_birth. Please specify at least one of these fields.",
340340
importance=Importance.BEST_PRACTICE_SUGGESTION,
341341
check_function_name="check_subject_age",
342342
object_type="Subject",

0 commit comments

Comments
 (0)