first commit
This commit is contained in:
commit
efa5080897
127 changed files with 18610 additions and 0 deletions
26
backend/app/kyc_validators.py
Normal file
26
backend/app/kyc_validators.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import re
|
||||
|
||||
PAN_PATTERN = re.compile(r"^[A-Z]{5}[0-9]{4}[A-Z]$")
|
||||
GST_PATTERN = re.compile(r"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z][1-9A-Z]Z[0-9A-Z]$")
|
||||
|
||||
|
||||
def normalize_pan(value: str) -> str:
|
||||
return value.strip().upper()
|
||||
|
||||
|
||||
def normalize_gst(value: str) -> str:
|
||||
return value.strip().upper()
|
||||
|
||||
|
||||
def validate_pan(value: str) -> str:
|
||||
pan = normalize_pan(value)
|
||||
if not PAN_PATTERN.match(pan):
|
||||
raise ValueError("PAN must match format ABCDE1234F")
|
||||
return pan
|
||||
|
||||
|
||||
def validate_gst(value: str) -> str:
|
||||
gst = normalize_gst(value)
|
||||
if not GST_PATTERN.match(gst):
|
||||
raise ValueError("GST must be a valid 15-character Indian GSTIN")
|
||||
return gst
|
||||
Loading…
Add table
Add a link
Reference in a new issue