Skip to content

Commit 9beee62

Browse files
[LABIMP - 6971] added validationn in initiate_create_project() , sending email in "created_by" field (#7)
* [LABIMP-6971] Annotation_guide is now conditionally required based on annotation_template_id presence. * [LABIMP-6971] Update error message for missing annotation_guide to clarify requirements * [LABIMP-6971] Added validation check in "created_by" field
1 parent a686849 commit 9beee62

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

labellerr/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# labellerr/client.py
2-
2+
import re
33
import requests
44
import uuid
55
from .exceptions import LabellerrError
@@ -1038,12 +1038,17 @@ def initiate_create_project(self, payload):
10381038
result = {}
10391039
# validate all the parameters
10401040
required_params = ['client_id', 'dataset_name', 'dataset_description', 'data_type', 'created_by', 'project_name','autolabel']
1041+
required_params = ['client_id', 'dataset_name', 'dataset_description', 'data_type', 'created_by', 'project_name','autolabel']
10411042
for param in required_params:
10421043
if param not in payload:
10431044
raise LabellerrError(f"Required parameter {param} is missing")
10441045
if param == 'client_id' and not isinstance(payload[param], str):
10451046
raise LabellerrError("client_id must be a non-empty string")
10461047

1048+
email = payload.get("created_by")
1049+
if not re.match(r"^[^@]+@[^@]+\.[^@]+$", email or ""):
1050+
raise LabellerrError("Please enter email id in created_by")
1051+
10471052
# annotation_guide is only required if annotation_template_id is not provided
10481053
if not payload.get('annotation_template_id'):
10491054
if 'annotation_guide' not in payload:
@@ -1054,7 +1059,7 @@ def initiate_create_project(self, payload):
10541059
if guide['option_type'] not in OPTION_TYPE_LIST:
10551060
raise LabellerrError(f"option_type must be one of {OPTION_TYPE_LIST}")
10561061

1057-
1062+
10581063
if 'folder_to_upload' in payload and 'files_to_upload' in payload:
10591064
raise LabellerrError("Cannot provide both files_to_upload and folder_to_upload")
10601065

0 commit comments

Comments
 (0)