Skip to main content

Spanish DNI utilities for NIE/NIF

Project description

Spanish DNI

SD is a library of utilities for the Python programming language that allows validating both NIE and NIF.

Installation

Can be installed via PiPI.

pip install spanish-dni

How to use it

from typing import List
from spanish_dni.dni import DNI
from spanish_dni.exceptions import NotValidDNIException
from spanish_dni.validator import validate_dni


my_dnis: List[str] = [
    "23414538D",
    "Y2853959H",
    "23418D",
    "U2853959H",
    "23414538T",
]


for dni in my_dnis:
    valid = True
    try:
        dni_parsed: DNI = validate_dni(dni)
        print(f"DNI {dni} is type {dni_parsed.dni_type}")
    except NotValidDNIException:
        valid = False
        print(f"DNI {dni} is not valid")

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

spanish-dni-1.0.1.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

spanish_dni-1.0.1-py3-none-any.whl (3.3 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