i18n¶
validators.i18n.es_cif(value)
¶
Validate a Spanish CIF.
Each company in Spain prior to 2008 had a distinct CIF and has been discontinued. For more information see wikipedia.org/cif.
The new replacement is to use NIF for absolutely everything. The issue is that there are "types" of NIFs now: company, person [citizen or resident] all distinguished by the first character of the DOI. For this reason we will continue to call CIFs NIFs, that are used for companies.
This validator is based on generadordni.es.
Examples:
>>> es_cif('B25162520')
True
>>> es_cif('B25162529')
ValidationError(func=es_cif, args={'value': 'B25162529'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
DOI string which is to be validated. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/es.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
validators.i18n.es_doi(value)
¶
Validate a Spanish DOI.
A DOI in spain is all NIF / CIF / NIE / DNI -- a digital ID. For more information see wikipedia.org/doi. This validator is based on generadordni.es.
Examples:
>>> es_doi('X0095892M')
True
>>> es_doi('X0095892X')
ValidationError(func=es_doi, args={'value': 'X0095892X'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
DOI string which is to be validated. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/es.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
validators.i18n.es_nie(value)
¶
Validate a Spanish NIE.
The NIE is a tax identification number in Spain, known in Spanish as the NIE, or more formally the Número de identidad de extranjero. For more information see wikipedia.org/nie. This validator is based on generadordni.es.
Examples:
>>> es_nie('X0095892M')
True
>>> es_nie('X0095892X')
ValidationError(func=es_nie, args={'value': 'X0095892X'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
DOI string which is to be validated. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/es.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
validators.i18n.es_nif(value)
¶
Validate a Spanish NIF.
Each entity, be it person or company in Spain has a distinct NIF. Since we've designated CIF to be a company NIF, this NIF is only for person. For more information see wikipedia.org/nif. This validator is based on generadordni.es.
Examples:
>>> es_nif('26643189N')
True
>>> es_nif('26643189X')
ValidationError(func=es_nif, args={'value': '26643189X'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
DOI string which is to be validated. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/es.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
validators.i18n.fi_business_id(value)
¶
Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more information see Finnish Trade Register
Examples:
>>> fi_business_id('0112038-9') # Fast Monkeys Ltd
True
>>> fi_business_id('1234567-8') # Bogus ID
ValidationError(func=fi_business_id, args={'value': '1234567-8'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Business ID string to be validated. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/fi.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
validators.i18n.fi_ssn(value, /, *, allow_temporal_ssn=True)
¶
Validate a Finnish Social Security Number.
This validator is based on django-localflavor-fi.
Examples:
>>> fi_ssn('010101-0101')
True
>>> fi_ssn('101010-0102')
ValidationError(func=fi_ssn, args={'value': '101010-0102'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Social Security Number to be validated. |
required |
allow_temporal_ssn |
bool
|
Whether to accept temporal SSN numbers. Temporal SSN numbers are the ones where the serial is in the range [900-999]. By default temporal SSN numbers are valid. |
True
|
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/fi.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
validators.i18n.fr_department(value)
¶
Validate a french department number.
Examples:
>>> fr_department(20) # can be an integer
ValidationError(func=fr_department, args={'value': 20})
>>> fr_department("20")
ValidationError(func=fr_department, args={'value': '20'})
>>> fr_department("971") # Guadeloupe
True
>>> fr_department("00")
ValidationError(func=fr_department, args={'value': '00'})
>>> fr_department('2A') # Corsica
True
>>> fr_department('2B')
True
>>> fr_department('2C')
ValidationError(func=fr_department, args={'value': '2C'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
Union[str, int]
|
French department number to validate. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/fr.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
validators.i18n.fr_ssn(value)
¶
Validate a french Social Security Number.
Each french citizen has a distinct Social Security Number. For more information see French Social Security Number (sadly unavailable in english).
Examples:
>>> fr_ssn('1 84 12 76 451 089 46')
True
>>> fr_ssn('1 84 12 76 451 089') # control key is optional
True
>>> fr_ssn('3 84 12 76 451 089 46') # wrong gender number
ValidationError(func=fr_ssn, args={'value': '3 84 12 76 451 089 46'})
>>> fr_ssn('1 84 12 76 451 089 47') # wrong control key
ValidationError(func=fr_ssn, args={'value': '1 84 12 76 451 089 47'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
French Social Security Number string to validate. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/fr.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
validators.i18n.ind_aadhar(value)
¶
Validate an indian aadhar card number.
Examples:
>>> ind_aadhar('3675 9834 6015')
True
>>> ind_aadhar('3675 ABVC 2133')
ValidationError(func=ind_aadhar, args={'value': '3675 ABVC 2133'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Aadhar card number string to validate. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/ind.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
validators.i18n.ind_pan(value)
¶
Validate a pan card number.
Examples:
>>> ind_pan('ABCDE9999K')
True
>>> ind_pan('ABC5d7896B')
ValidationError(func=ind_pan, args={'value': 'ABC5d7896B'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
PAN card number string to validate. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Source code in src/validators/i18n/ind.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
validators.i18n.ru_inn(value)
¶
Validate a Russian INN (Taxpayer Identification Number).
The INN can be either 10 digits (for companies) or 12 digits (for individuals). The function checks both the length and the control digits according to Russian tax rules.
Examples:
>>> ru_inn('500100732259') # Valid 12-digit INN
True
>>> ru_inn('7830002293') # Valid 10-digit INN
True
>>> ru_inn('1234567890') # Invalid INN
ValidationError(func=ru_inn, args={'value': '1234567890'})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
str
|
Russian INN string to validate. Can contain only digits. |
required |
Returns:
Type | Description |
---|---|
Literal[True]
|
If |
ValidationError
|
If |
Note
The validation follows the official algorithm: - For 10-digit INN: checks 10th control digit - For 12-digit INN: checks both 11th and 12th control digits
Source code in src/validators/i18n/ru.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|