pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python-validators/validators/commit/1462c7bb1b064b33d8b1c23dca99ef635baa4739

ous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-7a1ad343bd40328c.css" /> Update weights && add description function · python-validators/validators@1462c7b · GitHub
Skip to content

Commit 1462c7b

Browse files
TheDrunkenBearnandgator
authored andcommitted
Update weights && add description function
1 parent 014a6bb commit 1462c7b

1 file changed

Lines changed: 25 additions & 6 deletions

File tree

src/validators/inn.py

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

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

55

6-
@validator
7-
def inn(value: str):
8-
"""Description"""
6+
# @validator
7+
def inn(value: str, /):
8+
"""Return whether or not given value is a valid russian individual tax number.
9+
10+
Examples:
11+
>>> inn('7736050003')
12+
# Output: True
13+
>>> inn('781100086042')
14+
# Output: True
15+
16+
Args:
17+
value:
18+
Individual tax number string to validate
19+
20+
Returns:
21+
(Literal[True]): If `value` is a valid russian individual tax number.
22+
(ValidationError): If `value` is an invalid russian individual tax number.
23+
24+
Returns:
25+
26+
"""
927
if not value:
1028
return False
1129

@@ -18,10 +36,11 @@ def inn(value: str):
1836
return (control_number % 10) == digits[-1] if control_number > 9 else control_number == digits[-1]
1937
# person
2038
elif len(digits) == 12:
21-
weight_coefs1 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 6, 0, 0]
39+
weight_coefs1 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0, 0]
2240
control_number1 = sum([d * w for d, w in zip(digits, weight_coefs1)]) % 11
23-
weight_coefs2 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 0, 0, 0]
41+
weight_coefs2 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8, 0]
2442
control_number2 = sum([d * w for d, w in zip(digits, weight_coefs2)]) % 11
43+
print(control_number1, control_number2, value)
2544
return ((control_number1 % 10) == digits[-2] if control_number1 > 9 else control_number1 == digits[-2] and
2645
(control_number2 % 10) == digits[-1] if control_number2 > 9 else control_number2 == digits[-1])
2746
else:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy