Skip to content

[ 2449753 ] Combinations of key patterns and key names #428

@HolQue

Description

@HolQue

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'.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions