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
"""Validate that a predicate name starts with a letter/underscore."""
10
+
ifnotname:
11
+
raiseValueError("Predicate name cannot be empty")
12
+
ifnot_PREDICATE_RE.match(name):
13
+
ifname[0].isdigit():
14
+
raiseValueError(f"Predicate name '{name}' cannot start with a digit. Must start with a letter or underscore")
15
+
else:
16
+
raiseValueError(f"Predicate name '{name}' contains invalid characters. Must match [a-zA-Z_][a-zA-Z0-9_.\\-]*")
17
+
18
+
19
+
def_validate_component(name, context):
20
+
"""Validate that a component (entity) name contains only valid characters. May start with a digit."""
21
+
ifnotname:
22
+
raiseValueError(f"{context} name cannot be empty")
23
+
ifnot_COMPONENT_RE.match(name):
24
+
raiseValueError(f"{context} name '{name}' contains invalid characters. Must match [a-zA-Z0-9_][a-zA-Z0-9_.@\\-]*")
25
+
4
26
5
27
# Input validation work was implemented with the help of Claude Sonnet 4.5.
6
28
defparse_fact(fact_text):
@@ -75,28 +97,13 @@ def parse_fact(fact_text):
75
97
pred=pred_comp[:idx]
76
98
component=pred_comp[idx+1:-1]
77
99
78
-
# Validate predicate is not empty
79
-
ifnotpred:
80
-
raiseValueError("Predicate cannot be empty")
81
-
82
-
# Validate predicate contains only valid characters (alphanumeric and underscore)
83
-
# Predicates must start with a letter or underscore (like Python identifiers)
84
-
ifnotre.match(r'^[a-zA-Z_][a-zA-Z0-9_]*$', pred):
85
-
ifpred[0].isdigit():
86
-
raiseValueError(f"Predicate '{pred}' cannot start with a digit. Must start with a letter or underscore")
87
-
else:
88
-
raiseValueError(f"Predicate '{pred}' contains invalid characters. Only letters, digits, and underscores allowed, must start with letter or underscore")
0 commit comments