-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform_validate.py
57 lines (54 loc) · 1.46 KB
/
form_validate.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def isfloat(num):
try:
float(num)
return True
except ValueError:
return False
def isint(num):
try:
int(num)
return True
except ValueError:
return False
def validate(output):
error = False
if output["sym"]=="Symmentrical":
if isfloat(output["space"]) == False:
error = True
else:
if isfloat(output["space_12"]) == False:
error = True
if isfloat(output["space_23"]) == False:
error = True
if isfloat(output["space_31"]) == False:
error = True
if isint(output["n_strand"]) == False:
error = True
else:
allow=[1,7,19,37,61]
if not int(output["n_strand"]) in allow:
error = True
if isfloat(output["sub_space"]) == False:
error = True
if isint(output["n_sub_con"]) == False:
error = True
if isfloat(output["strand_dm"]) == False:
error = True
if isfloat(output["len"]) == False:
error = True
if isfloat(output["R"]) == False:
error = True
if isfloat(output["f"]) == False:
error = True
if isfloat(output["V"]) == False:
error = True
if isfloat(output["L"]) == False:
error = True
if isfloat(output["pf"]) == False:
error = True
else:
if float(output["pf"]) > 1 or float(output["pf"]) < -1:
error = True
return error
if __name__=="__main__":
print('VALIDATE')