Skip to content

Commit 06151dc

Browse files
add function description and fix validators imports
1 parent 5828572 commit 06151dc

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

src/validators/i18n/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from .fi import fi_business_id, fi_ssn
66
from .fr import fr_department, fr_ssn
77
from .ind import ind_aadhar, ind_pan
8-
from .ru_inn import ru_inn
8+
from .ru import ru_inn
99

1010
__all__ = (
1111
"fi_business_id",
@@ -18,6 +18,5 @@
1818
"fr_ssn",
1919
"ind_aadhar",
2020
"ind_pan",
21-
# Russian Individual Tax Number
2221
"ru_inn"
2322
)

src/validators/i18n/ru_inn.py renamed to src/validators/i18n/ru.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
"""Inn."""
1+
"""Russia INN."""
22

3-
from src.validators.utils import validator
3+
from validators.utils import validator
44

55

66
@validator
7-
def ru_inn(value: str, /):
8-
"""Return whether or not given value is a valid russian individual tax number.
7+
def ru_inn(value: str):
8+
"""Validate a Russian INN (Taxpayer Identification Number).
99
10-
This validator is algorithm [1].
11-
12-
[1]: https://ru.wikipedia.org/wiki/Идентификационный_номер_налогоплательщика
10+
The INN can be either 10 digits (for companies) or 12 digits (for individuals).
11+
The function checks both the length and the control digits according to Russian tax rules.
1312
1413
Examples:
15-
>>> inn('7736050003')
16-
# Output: True
17-
>>> inn('781100086042')
18-
# Output: True
14+
>>> ru_inn('500100732259') # Valid 12-digit INN
15+
True
16+
>>> ru_inn('7830002293') # Valid 10-digit INN
17+
True
18+
>>> ru_inn('1234567890') # Invalid INN
19+
ValidationFailure(func=ru_inn, args={'value': '1234567890'})
1920
2021
Args:
21-
value:
22-
Individual tax number string to validate
23-
24-
Returns:
25-
(Literal[True]): If `value` is a valid russian individual tax number.
26-
(ValidationError): If `value` is an invalid russian individual tax number.
22+
value: Russian INN string to validate. Can contain only digits.
2723
2824
Returns:
25+
(Literal[True]): If `value` is a valid Russian INN.
26+
(ValidationError): If `value` is an invalid Russian INN.
2927
28+
Note:
29+
The validation follows the official algorithm:
30+
- For 10-digit INN: checks 10th control digit
31+
- For 12-digit INN: checks both 11th and 12th control digits
3032
"""
3133
if not value:
3234
return False

tests/i18n/test_ru_inn.py renamed to tests/i18n/test_ru.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import pytest
55

66
# local
7-
from src.validators import ValidationError
8-
from src.validators.i18n import ru_inn
7+
from validators import ValidationError
8+
from validators.i18n.ru import ru_inn
99

1010

1111
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)