-
Notifications
You must be signed in to change notification settings - Fork 1
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
Derek furst/add creation action #538
Changes from 4 commits
1aa6c86
75f4c33
a5a1fd8
2dc0808
af8ac17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -509,6 +509,27 @@ def validate_publication_date(property_key, normalized_entity_type, request, exi | |
except ValueError: | ||
raise ValueError(f"Invalid {property_key} format, must be YYYY-MM-DD") | ||
|
||
""" | ||
Validate the provided value of the activity creation action. Only very specific | ||
values are allowed. | ||
Parameters | ||
---------- | ||
property_key : str | ||
The target property key | ||
normalized_type : str | ||
Submission | ||
request: Flask request object | ||
The instance of Flask request passed in from application request | ||
existing_data_dict : dict | ||
A dictionary that contains all existing entity properties | ||
new_data_dict : dict | ||
The json data in request body, already after the regular validations | ||
""" | ||
def validate_creation_action(property_key, normalized_entity_type, request, existing_data_dict, new_data_dict): | ||
creation_action = new_data_dict[property_key] | ||
if creation_action and creation_action not in ["Central Process", "Lab Process", "Multi-Assay Split"]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is when the provided I would also make this string match case-insensitive so it's more fault-tolerant, just like the way we check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yuanzhou I changed |
||
raise ValueError(f"Invalid {property_key} value") | ||
|
||
|
||
#################################################################################################### | ||
## Internal Functions | ||
|
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.
This condition will cause
KeyError: 'creation_action'
for whencreation_action
field is not provided in the request, which will result 500 error. Need to check the existence of the key and no need to keep the non-empty check since the validator should have handled that.