-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RCT/JDJ/validation associated list length #1643
base: develop
Are you sure you want to change the base?
Conversation
if has_key_1 or has_key_2: | ||
if not (has_key_1 and has_key_2): # One key is missing | ||
mismatch_errors.append( | ||
f"'{obj['id']}' has populated '{key_1 if has_key_1 else key_2}' but is missing '{key_1 if not has_key_1 else key_2}'." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function run after the schema validation? Just making sure the ["id"]
is well covered.
for obj in object_list: | ||
for key_1, key_2 in associated_list_data_elements: | ||
has_key_1 = key_1 in obj | ||
has_key_2 = key_2 in obj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to do it - save an if
for obj in object_list:
for key_1, key_2 in associated_list_data_elements:
val_1, val_2 = obj.get(key_1, None), obj(key_2, None)
# XOR operation
if val_1 is None != val_2 is None:
mismatch_errors.append(
f"'{obj['id']}' has populated '{key_1 if val_1 else key_2}' but is missing '{key_1 if not val_1 else key_2}'."
isinstance(val_1, list) | ||
and isinstance(val_2, list) | ||
and len(val_1) != len(val_2) | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If schema validation has run before this function, then here you can simply do val_1 and val_2 and len(val_1) != len(val_2)
But I do also like to check for list to specify these values shall be list.
No description provided.