|
|
@@ -3,7 +3,9 @@ import re
|
|
|
class validators_base:
|
|
|
@staticmethod
|
|
|
def _validate_generic_name(content: str, name: str = "it") -> str:
|
|
|
- if re.search("\W ", content) is not None:
|
|
|
+ copy = content.replace("-", "").replace("_", "")
|
|
|
+
|
|
|
+ if not copy.isalpha():
|
|
|
raise ValueError(
|
|
|
name.title() + " can contain only _ and alphanumeric chars."
|
|
|
)
|
|
|
@@ -12,7 +14,12 @@ class validators_base:
|
|
|
|
|
|
@staticmethod
|
|
|
def _validate_white_chars(content: str, name: str = "it") -> str:
|
|
|
- if re.search("\s", content) is not None:
|
|
|
+ contain = str(" ") in content
|
|
|
+ contain = contain or str("\t") in content
|
|
|
+ contain = contain or str("\r") in content
|
|
|
+ contain = contain or str("\n") in content
|
|
|
+
|
|
|
+ if contain:
|
|
|
raise ValueError(
|
|
|
name.title() + " can not contain whitespace chars."
|
|
|
)
|