@@ -73,6 +73,34 @@ def validate_recognized_dataset_type(property_key, normalized_entity_type, reque
7373 raise ValueError (f"Proposed Dataset dataset_type '{ proposed_dataset_type_prefix } '"
7474 f" is not recognized in the existing ontology."
7575 f" Valid values are: { str (target_list )} ." )
76+
77+
78+ """
79+ Validate the specified value for an Upload's intended_dataset_type is in the valueset UBKG recognizes.
80+
81+ Parameters
82+ ----------
83+ property_key : str
84+ The target property key
85+ normalized_type : str
86+ Submission
87+ request: Flask request object
88+ The instance of Flask request passed in from application request
89+ existing_data_dict : dict
90+ A dictionary that contains all existing entity properties
91+ new_data_dict : dict
92+ The json data in request body, already after the regular validations
93+ """
94+ def validate_intended_dataset_type (property_key , normalized_entity_type , request , existing_data_dict , new_data_dict ):
95+ # If the proposed Upload intended_dataset_type ends with something in square brackets, anything inside
96+ # those square brackets are acceptable at the end of the string. Simply validate the start.
97+ proposed_dataset_type_prefix = re .sub (pattern = '(\S)\s\[.*\]$' , repl = r'\1' , string = new_data_dict ['intended_dataset_type' ])
98+ target_list = schema_manager .get_dataset_type_valueset_list ()
99+
100+ if proposed_dataset_type_prefix not in target_list :
101+ raise ValueError (f"Proposed Upload intended_dataset_type '{ proposed_dataset_type_prefix } '"
102+ f" is not recognized in the existing ontology."
103+ f" Valid values are: { str (target_list )} ." )
76104
77105
78106"""
0 commit comments