File tree Expand file tree Collapse file tree 3 files changed +22
-21
lines changed Expand file tree Collapse file tree 3 files changed +22
-21
lines changed Original file line number Diff line number Diff line change 55from .fi import fi_business_id , fi_ssn
66from .fr import fr_department , fr_ssn
77from .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" ,
1818 "fr_ssn" ,
1919 "ind_aadhar" ,
2020 "ind_pan" ,
21- # Russian Individual Tax Number
2221 "ru_inn"
2322)
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 44import 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 (
You can’t perform that action at this time.
0 commit comments