Skip to main content

Python package for validating Uruguayan identity document numbers.

Project description


🇺🇾 🇪🇸 Documentación en español disponible aquí / Spanish documentation is available here.

Package for validating Uruguayan identity document numbers. Full documentation is available here.

The functions in this package work with strings and ignore any non-digit characters. Numbers are valid too. So for example, the following expressions represent the same document number:


This package includes the following functions:

validate_ci(ci: str) -> bool: Returns true if ci is a valid document number, returns false otherwise. ci is a string which represents a document number, including the validation digit. ci can be a number as well.

validation_digit(ci: str) -> str: Returns the validation digit for ci.

random() -> str: Returns a random document number (including validation digit) in the (100.000, 9.999.999) range.


$ pip install ciuy


>>> import ciuy
>>> ciuy.validate_ci("1.234.567-2")
>>> ciuy.validation_digit("1.234.567")
>>> ciuy.random()


This package includes some doctests, as well as unit tests that can be run with pytest.

After cloning the repository, you can run the doctests with:

$ python3 -m doctest ./ciuy/ -v
 (several lines ommited)
11 passed and 0 failed.
Test passed.

Use py.test to run the unit tests:

$ py.test
============================= test session starts ==============================
platform linux -- Python 3.8.1, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /home/ciuy
collected 98 items     

tests\ ..........                                           [ 10%]
tests\ ........................                      [ 34%]
tests\ ..                                               [ 36%]
tests\ .......................................        [ 76%]
tests\ .......................                   [100%]

============================== 98 passed in 1.09s =============================

You can also use pytest to run all tests, including doctests, with:

$ py.test --doctest-modules

Command line

After installation, the following commands become available:

$ validate_ci 1.234.567-2
$ validation_digit 1.234.567
$ random_ci

Based on the ci_uy Ruby gem by Fernando Briano (link).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ciuy-1.0.0.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

ciuy-1.0.0-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page