first commit
This commit is contained in:
commit
efa5080897
127 changed files with 18610 additions and 0 deletions
38
backend/app/sender_validators.py
Normal file
38
backend/app/sender_validators.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import re
|
||||
|
||||
SENDER_ID_PATTERN = re.compile(r"^[A-Z0-9]{3,11}$")
|
||||
DLT_ENTITY_PATTERN = re.compile(r"^\d{12,25}$")
|
||||
|
||||
|
||||
def normalize_sender_id(value: str) -> str:
|
||||
return value.strip().upper()
|
||||
|
||||
|
||||
def validate_sender_id(value: str) -> str:
|
||||
sender_id = normalize_sender_id(value)
|
||||
if not SENDER_ID_PATTERN.match(sender_id):
|
||||
raise ValueError("Sender ID must be 3–11 uppercase letters or numbers")
|
||||
return sender_id
|
||||
|
||||
|
||||
def validate_sender_type(value: str) -> str:
|
||||
normalized = value.strip().lower()
|
||||
if normalized not in {"promotional", "transactional"}:
|
||||
raise ValueError("Type must be promotional or transactional")
|
||||
return normalized
|
||||
|
||||
|
||||
def validate_purpose(value: str) -> str:
|
||||
purpose = value.strip()
|
||||
if len(purpose) < 10:
|
||||
raise ValueError("Purpose must be at least 10 characters")
|
||||
if len(purpose) > 500:
|
||||
raise ValueError("Purpose must be 500 characters or fewer")
|
||||
return purpose
|
||||
|
||||
|
||||
def validate_dlt_entity_id(value: str) -> str:
|
||||
entity_id = value.strip()
|
||||
if not DLT_ENTITY_PATTERN.match(entity_id):
|
||||
raise ValueError("DLT Entity ID must be 12–25 digits")
|
||||
return entity_id
|
||||
Loading…
Add table
Add a link
Reference in a new issue