TOXRA.AI / core /validate.py
hchevva's picture
Create validate.py
5bfa58c verified
raw
history blame contribute delete
321 Bytes
import re
CAS_RX = re.compile(r"^\d{2,7}-\d{2}-\d$")
DTXSID_RX = re.compile(r"^DTXSID\d{7,}$")
def is_cas(s: str) -> bool:
return bool(CAS_RX.match((s or "").strip()))
def normalize_cas(s: str) -> str:
return (s or "").strip()
def is_dtxsid(s: str) -> bool:
return bool(DTXSID_RX.match((s or "").strip()))