Refactoring
This commit is contained in:
parent
d396b33686
commit
e00b1a128c
@ -69,7 +69,8 @@ class textAttribute(Attribute):
|
||||
return f"Max length must be greater than min length for '{self.attrib_name}'."
|
||||
if self.default_val is not None:
|
||||
if self.regex is not None:
|
||||
if not re.match(self.regex, str(self.default_val)):
|
||||
compiled_regex = re.compile(self.regex)
|
||||
if not compiled_regex.match(str(self.default_val)):
|
||||
return f"Default value for '{self.attrib_name}' must match the pattern: {self.regex}"
|
||||
if self.allowed_chars is not None:
|
||||
for char in self.default_val:
|
||||
@ -116,8 +117,10 @@ class intAttribute(Attribute):
|
||||
return f"Step must be an integer for attribute '{self.attrib_name}'."
|
||||
if self.step <= 0:
|
||||
return f"Step must be a positive integer for attribute '{self.attrib_name}'."
|
||||
if self.min_val is not None and self.max_val is not None and self.step > (self.max_val - self.min_val):
|
||||
return f"Step value is too large for attribute '{self.attrib_name}'."
|
||||
if self.min_val is not None and self.max_val is not None:
|
||||
range_val = self.max_val - self.min_val
|
||||
if self.step > range_val:
|
||||
return f"Step value is too large for attribute '{self.attrib_name}'."
|
||||
if self.default_val is not None:
|
||||
if not isinstance(self.default_val, int):
|
||||
return f"default_val must be an integer for attribute '{self.attrib_name}'."
|
||||
@ -160,8 +163,10 @@ class floatAttribute(Attribute):
|
||||
return f"Step must be an float for attribute '{self.attrib_name}'."
|
||||
if self.step <= 0:
|
||||
return f"Step must be a positive float for attribute '{self.attrib_name}'."
|
||||
if self.min_val is not None and self.max_val is not None and self.step > (self.max_val - self.min_val):
|
||||
return f"Step value is too large for attribute '{self.attrib_name}'."
|
||||
if self.min_val is not None and self.max_val is not None:
|
||||
range_val = self.max_val - self.min_val
|
||||
if self.step > range_val:
|
||||
return f"Step value is too large for attribute '{self.attrib_name}'."
|
||||
if self.default_val is not None:
|
||||
if not isinstance(self.default_val, float):
|
||||
return f"default_val must be a number for attribute '{self.attrib_name}'."
|
||||
|
Loading…
Reference in New Issue
Block a user