You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: minds/utils.py
+24-1
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,30 @@
1
1
importre
2
2
importminds.exceptionsasexc
3
3
4
+
defvalidate_mind_name(mind_name):
5
+
"""
6
+
Validate the Mind name.
7
+
8
+
A valid Mind name should:
9
+
- Start with a letter
10
+
- Contain only letters, numbers, or underscores
11
+
- Have a maximum length of 32 characters
12
+
- Not contain spaces
13
+
14
+
Parameters:
15
+
mind_name (str): The Mind name to validate.
16
+
17
+
Returns:
18
+
bool: True if valid, False otherwise.
19
+
"""
20
+
# Regular expression pattern
21
+
pattern=r'^[A-Za-z][A-Za-z0-9_]{0,31}$'
22
+
23
+
# Check if the Mind name matches the pattern
24
+
ifnotre.match(pattern, mind_name):
25
+
raiseexc.MindNameInvalid("Mind name should start with a letter and contain only letters, numbers or underscore, with a maximum of 32 characters. Spaces are not allowed.")
# Check if the datasource name matches the pattern
24
48
ifnotre.match(pattern, ds_name):
25
49
raiseexc.DatasourceNameInvalid("Datasource name should start with a letter and contain only letters, numbers or underscore, with a maximum of 62 characters. Spaces are not allowed.")
0 commit comments