File tree 3 files changed +22
-21
lines changed
3 files changed +22
-21
lines changed Original file line number Diff line number Diff line change 5
5
from .fi import fi_business_id , fi_ssn
6
6
from .fr import fr_department , fr_ssn
7
7
from .ind import ind_aadhar , ind_pan
8
- from .ru_inn import ru_inn
8
+ from .ru import ru_inn
9
9
10
10
__all__ = (
11
11
"fi_business_id" ,
18
18
"fr_ssn" ,
19
19
"ind_aadhar" ,
20
20
"ind_pan" ,
21
- # Russian Individual Tax Number
22
21
"ru_inn"
23
22
)
Original file line number Diff line number Diff line change 1
- """Inn ."""
1
+ """Russia INN ."""
2
2
3
- from src . validators .utils import validator
3
+ from validators .utils import validator
4
4
5
5
6
6
@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) .
9
9
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.
13
12
14
13
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'})
19
20
20
21
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.
27
23
28
24
Returns:
25
+ (Literal[True]): If `value` is a valid Russian INN.
26
+ (ValidationError): If `value` is an invalid Russian INN.
29
27
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
30
32
"""
31
33
if not value :
32
34
return False
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
# 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
9
9
10
10
11
11
@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments