i18n¶
- validators.i18n.es_cif(value: str, /)¶
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][1].
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][2].
[1]: https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal [2]: https://generadordni.es/
Examples
>>> es_cif('B25162520') True >>> es_cif('B25162529') ValidationError(func=es_cif, args={'value': 'B25162529'})
- Parameters:
value – DOI string which is to be validated.
- Returns:
If value is a valid DOI string. (ValidationError): If value is an invalid DOI string.
- Return type:
(Literal[True])
- validators.i18n.es_doi(value: str, /)¶
Validate a Spanish DOI.
A DOI in spain is all NIF / CIF / NIE / DNI – a digital ID. For more information see [wikipedia.org/doi][1]. This validator is based on [generadordni.es][2].
[1]: https://es.wikipedia.org/wiki/Identificador_de_objeto_digital [2]: https://generadordni.es/
Examples
>>> es_doi('X0095892M') True >>> es_doi('X0095892X') ValidationError(func=es_doi, args={'value': 'X0095892X'})
- Parameters:
value – DOI string which is to be validated.
- Returns:
If value is a valid DOI string. (ValidationError): If value is an invalid DOI string.
- Return type:
(Literal[True])
- validators.i18n.es_nie(value: str, /)¶
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][1]. This validator is based on [generadordni.es][2].
[1]: https://es.wikipedia.org/wiki/N%C3%BAmero_de_identidad_de_extranjero [2]: https://generadordni.es/
Examples
>>> es_nie('X0095892M') True >>> es_nie('X0095892X') ValidationError(func=es_nie, args={'value': 'X0095892X'})
- Parameters:
value – DOI string which is to be validated.
- Returns:
If value is a valid DOI string. (ValidationError): If value is an invalid DOI string.
- Return type:
(Literal[True])
- validators.i18n.es_nif(value: str, /)¶
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][1]. This validator is based on [generadordni.es][2].
[1]: https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal [2]: https://generadordni.es/
Examples
>>> es_nif('26643189N') True >>> es_nif('26643189X') ValidationError(func=es_nif, args={'value': '26643189X'})
- Parameters:
value – DOI string which is to be validated.
- Returns:
If value is a valid DOI string. (ValidationError): If value is an invalid DOI string.
- Return type:
(Literal[True])
- validators.i18n.fi_business_id(value: str, /)¶
Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more information see [Finnish Trade Register][1]
[1]: http://en.wikipedia.org/wiki/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:
value – Business ID string to be validated.
- Returns:
If value is a valid finnish business id. (ValidationError): If value is an invalid finnish business id.
- Return type:
(Literal[True])
- validators.i18n.fi_ssn(value: str, /, *, allow_temporal_ssn: bool = True)¶
Validate a Finnish Social Security Number.
This validator is based on [django-localflavor-fi][1].
[1]: https://github.com/django/django-localflavor-fi/
Examples
>>> fi_ssn('010101-0101') True >>> fi_ssn('101010-0102') ValidationError(func=fi_ssn, args={'value': '101010-0102'})
- Parameters:
value – Social Security Number to be validated.
allow_temporal_ssn – 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.
- Returns:
If value is a valid finnish SSN. (ValidationError): If value is an invalid finnish SSN.
- Return type:
(Literal[True])
- validators.i18n.fr_department(value: str | int)¶
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:
value – French department number to validate.
- Returns:
If value is a valid french department number. (ValidationError): If value is an invalid french department number.
- Return type:
(Literal[True])
- validators.i18n.fr_ssn(value: str)¶
Validate a french Social Security Number.
Each french citizen has a distinct Social Security Number. For more information see [French Social Security Number][1] (sadly unavailable in english).
[1]: https://fr.wikipedia.org/wiki/Num%C3%A9ro_de_s%C3%A9curit%C3%A9_sociale_en_France
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:
value – French Social Security Number string to validate.
- Returns:
If value is a valid french Social Security Number. (ValidationError): If value is an invalid french Social Security Number.
- Return type:
(Literal[True])
- validators.i18n.ind_aadhar(value: str)¶
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:
value – Aadhar card number string to validate.
- Returns:
If value is a valid aadhar card number. (ValidationError): If value is an invalid aadhar card number.
- Return type:
(Literal[True])
- validators.i18n.ind_pan(value: str)¶
Validate a pan card number.
Examples
>>> ind_pan('ABCDE9999K') True >>> ind_pan('ABC5d7896B') ValidationError(func=ind_pan, args={'value': 'ABC5d7896B'})
- Parameters:
value – PAN card number string to validate.
- Returns:
If value is a valid PAN card number. (ValidationError): If value is an invalid PAN card number.
- Return type:
(Literal[True])
- validators.i18n.ru_inn(value: str)¶
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:
value – Russian INN string to validate. Can contain only digits.
- Returns:
If value is a valid Russian INN. (ValidationError): If value is an invalid Russian INN.
- Return type:
(Literal[True])
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