Skip to content
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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

JacksonJ-KC
Copy link
Collaborator

No description provided.

@JacksonJ-KC JacksonJ-KC self-assigned this Feb 12, 2025
@JacksonJ-KC JacksonJ-KC changed the base branch from master to develop February 12, 2025 14:30
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}'."
Copy link
Collaborator

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
Copy link
Collaborator

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)
):
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants