Skip to main content

Gestión de cédulas uruguayas con validación de dígitos verificadores

Project description

CedulaUruguaya

The CedulaUruguaya package provides a set of tools for managing and validating Uruguayan ID numbers (Cédulas de Identidad). It includes functions to validate these IDs, calculate verification digits, format them in a standard way, and more. This package aims to simplify operations related to Uruguayan IDs in various applications, from data validation to user interface enhancements.

Features

get_validation_digit(ci)

Calculates the verification digit for a given Uruguayan ID number (without the verification digit).

  • Parameters:

    • ci (int): The ID number without its last verification digit.
  • Returns:

    • int: The calculated verification digit.
  • Example:

    print(CedulaUruguaya.get_validation_digit(3298763))  # Output: 4
    

clean_ci(ci)

Cleans an ID number by removing non-numeric characters such as dots and dashes.

  • Parameters:

    • ci (str/int): The ID number as a string or integer, potentially formatted with dots or dashes.
  • Returns:

    • int: The cleaned numeric ID.
  • Example:

    print(CedulaUruguaya.clean_ci("3.298.763-4"))  # Output: 32987634
    

validate_ci(ci)

Validates a complete Uruguayan ID number by comparing its last digit against the calculated verification digit.

  • Parameters:

    • ci (str/int): The complete ID number.
  • Returns:

    • bool: True if the ID is valid, False otherwise.
  • Example:

    print(CedulaUruguaya.validate_ci("3.298.763-4"))  # Output: True
    

format_ci(ci)

Formats an ID number into a more visually friendly format (X.XXX.XXX-X).

  • Parameters:

    • ci (int/str): The ID number to format.
  • Returns:

    • str: The formatted ID.
  • Example:

    print(CedulaUruguaya.format_ci(32987634))  # Output: '3.298.763-4'
    

random_ci_in_range(start, end)

Generates a random Uruguayan ID number within a specified range, including the verification digit.

  • Parameters:

    • start (int): Lower bound of the ID range.
    • end (int): Upper bound of the ID range.
  • Returns:

    • int: A valid ID number.
  • Example:

    print(CedulaUruguaya.random_ci_in_range(1000000, 2000000))
    

international_format(ci)

Converts a local ID format to an international format prefixed with UY-.

  • Parameters:

    • ci (int/str): The ID number.
  • Returns:

    • str: The internationally formatted ID.
  • Example:

    print(CedulaUruguaya.international_format(32987634))  # Output: 'UY-3.298.763-4'
    

bulk_validate_ci(ci_list)

Validates a list of IDs in one operation, returning a dictionary with the IDs and their validation results.

  • Parameters:

    • ci_list (list): A list of complete ID numbers.
  • Returns:

    • dict: A dictionary with IDs as keys and validation results (True or False) as values.
  • Example:

    print(CedulaUruguaya.bulk_validate_ci(["3.298.763-4", "1.234.567-8"]))
    

Installation

To install the CedulaUruguaya package, run the following command:

pip install cedula_uruguaya

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

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

cedula_uruguaya-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cedula_uruguaya-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file cedula_uruguaya-0.1.0.tar.gz.

File metadata

  • Download URL: cedula_uruguaya-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.10

File hashes

Hashes for cedula_uruguaya-0.1.0.tar.gz
Algorithm Hash digest
SHA256 13c6637da4cb2a532bae7cb81c02f73ae730b2bdffc5fbf7ae9f2601554f7225
MD5 1c618e980e17a03defa92c2fdeee597b
BLAKE2b-256 1f160d3e42059c51b65d21f31196eeba07312bb60447d00a06119a3a6f66b508

See more details on using hashes here.

File details

Details for the file cedula_uruguaya-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cedula_uruguaya-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4822e0e0105a591a9c52fb407e9c2eacff1195e678ef7cca36c4a62086a1da7
MD5 7ce4e11fbf96ea143fc0f91d309789d2
BLAKE2b-256 4b303cae3081a87240502a282d0f76f3f6ad6e0a58358c801e5344cfc92a3cb7

See more details on using hashes here.

Supported by

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