diff --git a/projects/PiNetAI/utils/string_utils.py b/projects/PiNetAI/utils/string_utils.py new file mode 100644 index 000000000..50b216e90 --- /dev/null +++ b/projects/PiNetAI/utils/string_utils.py @@ -0,0 +1,14 @@ +# string_utils.py + +import re + +def validate_email(email): + pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" + return re.match(pattern, email) is not None + +def validate_password(password): + pattern = r"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$" + return re.match(pattern, password) is not None + +def truncate_string(string, length): + return string[:length] + "..." if len(string) > length else string