File: //opt/alt/python311/lib/python3.11/site-packages/validators/i18n/__pycache__/es.cpython-311.pyc
�
�;f� � �� � d Z ddlmZmZ ddlmZ dedeeef dee fd�Zedefd�� � Zedefd �� � Z edefd
�� � Z
edefd�� � ZdS )
zSpain.� )�Dict�Set)� validator�value�number_by_letter�
special_casesc �& � | |v st | � � dk rdS | � � � } d}|� | d | d � � | dd� z }|� � � o!| d |t |� � dz k S )z&Validate if the doi is a NIF or a NIE.� F�TRWAGMYFPDXBNJZSQVHLCKEr � � � )�len�upper�get�isdigit�int)r r r �table�numberss �E/opt/alt/python311/lib/python3.11/site-packages/validators/i18n/es.py�_nif_nie_validationr
s� � ��
����U���q����u��K�K�M�M�E�%�E� �"�"�5��8�U�1�X�6�6��q��s��C�G��?�?���E��q��U�3�w�<�<�"�3D�-E�!E�E� c � � | rt | � � dk rdS | � � � } d}| d }| dd� }| d }|� � � sdS dt d� t |� � D � � � � dz z
dz }|d v rt |� � |k S |d
v r|| |k S |dv r|t |� � || hv ndS )a� 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')
# Output: True
>>> es_cif('B25162529')
# Output: ValidationError(func=es_cif, args=...)
Args:
value:
DOI string which is to be validated.
Returns:
(Literal[True]): If `value` is a valid DOI string.
(ValidationError): If `value` is an invalid DOI string.
r
F�
JABCDEFGHIr r r
�
c 3 �� K � | ]^\ }}|d z dk r?t t t t t |� � d z � � � � � � nt |� � V � �_dS )� r N)�sum�mapr �str)�.0�index�chars r � <genexpr>zes_cif.<locals>.<genexpr>A sw � � � �
�
� ��t� 27���a���C��C��S��Y�Y��]�+�+�,�,�-�-�-�S��Y�Y�
�
�
�
�
�
r �ABEH�PSQW� CDFGJNRUV)r r r r � enumerater )r r � first_chr�doi_body�control�ress r �es_cifr- s � �>