herolib_python/_archive/osis/datatools.py
2025-08-05 15:15:36 +02:00

14 lines
507 B
Python

import re
def normalize_email(email: str) -> str:
# Normalize email by stripping spaces and converting to lower case
#EmailStr.validate(email) #TODO
return email.strip().lower()
def normalize_phone(phone: str) -> str:
# Normalize phone number by removing dots and spaces, and ensure it matches the pattern +<digits>
phone = phone.replace(".", "").replace(" ", "")
if not re.match(r"^\+\d+$", phone):
raise ValueError(f"Invalid phone number: {phone}")
return phone