Skip to content

Commit 56f0210

Browse files
TheDrunkenBearyozachar
authored andcommitted
Validators inn company
1 parent 640763f commit 56f0210

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/validators/inn.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
"""Inn."""
22

3-
from .utils import validator
3+
# from .utils import validator
44

55

6-
@validator
6+
# @validator
77
def inn(value: str):
8-
pass
8+
"""Description"""
9+
if not value:
10+
return False
11+
12+
try:
13+
digits = list(map(int, value))
14+
# person
15+
if len(digits) == 10:
16+
weight_coefs = [2, 4, 10, 3, 5, 9, 4, 6, 8, 0]
17+
control_number = sum([d * w for d, w in zip(digits, weight_coefs)]) % 11
18+
return (control_number % 10) == digits[-1] if control_number > 9 else control_number == digits[-1]
19+
# company
20+
elif len(digits) == 12:
21+
pass
22+
# error inn
23+
else:
24+
return False
25+
except ValueError:
26+
return False
27+
28+
if "__main__" == __name__:
29+
print(inn('5260355389'))

0 commit comments

Comments
 (0)