Skip to content
Snippets Groups Projects

model.base: fix id_short validation

Merged Leon Mauritz Möller requested to merge backport/id_short_validation into master
2 files
+ 5
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 2
2
@@ -461,9 +461,9 @@ class Referable(metaclass=abc.ABCMeta):
if id_short is None and not hasattr(self, 'identification'):
raise ValueError("The id_short for not identifiable elements is mandatory")
test_id_short: str = str(id_short)
if not re.match("^[a-zA-Z0-9_]*$", test_id_short):
if not re.fullmatch("[a-zA-Z0-9_]*", test_id_short):
raise ValueError("The id_short must contain only letters, digits and underscore")
if not re.match("^([a-zA-Z].*|)$", test_id_short):
if len(test_id_short) > 0 and not test_id_short[0].isalpha():
raise ValueError("The id_short must start with a letter")
if self.parent is not None and id_short != self.id_short:
Loading