-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Three examples: (1) and (2) are fine, w.r.t. (3) I have doubts
(1)
keyPattern = r'^\d+$'
together with
"ABC" : "value"
causes
Error: 'Error: Key name 'ABC' is invalid. Expected format: '^\d+$''!
(like expected)
(2)
keyPattern = r'^\d*$'
together with
"ABC" : "value"
causes
Error: 'Error: Key name 'ABC' is invalid. Expected format: '^\d*$''!
(like expected)
(3)
keyPattern = r'^\d*$'
together with
"" : "value"
causes
DotDict({'': 'value'})
But an empty key name should not be accepted. The question here is: How to detect, that a regular expression would allow an empty string?
This might help:
if re.fullmatch(pattern, ""):
print("Matches empty string")
else:
print("Does not match empty string")
In first case the JsonPreprocessor should raise an exception about an invalid 'keyPattern'.