-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidityfunctions.py
More file actions
41 lines (28 loc) · 831 Bytes
/
validityfunctions.py
File metadata and controls
41 lines (28 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import re
from databaseConnections import db_user
def check_aadhar_validity(aadharNo):
# return -1 if aadhar is invalid
result = re.search('[\D]', aadharNo)
if len(aadharNo) is not 12 or result is not None:
return -1
else:
return 1
def check_contact_validity(contactNo):
# return -1 if contact number is invalid
result = re.search('[\D]', contactNo)
if len(contactNo) is not 10 or result is not None:
return -1
else:
return 1
def check_aadhar_in_DB(aadharNo):
valid = db_user.find_one({'AadharNo': aadharNo})
if valid is not None:
return 1
else:
return -1
def check_zip_code(zip_code):
result = re.search('[\D]', zip_code)
if len(zip_code) is not 6 and result is not None:
return -1
else:
return 1