
    b?1i                         d Z ddlmZmZ ddlmZ dedeeef   dee   fdZedefd       Zedefd	       Z	edefd
       Z
edefd       Zy)zSpain.    )DictSet)	validatorvaluenumber_by_letterspecial_casesc                     | |v st        |       dk7  ry| j                         } d}|j                  | d   | d         | dd z   }|j                         xr | d   |t	        |      dz     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        \/home/www/therecruiter.miabetepe.com/venv/lib/python3.12/site-packages/validators/i18n/es.py_nif_nie_validationr   
   sw    UqKKME%E ""58U1X6qCG??EqU3w<"3D-E!EE    c                <   | rt        |       dk7  ry| j                         } d}| d   }| dd }| d   }|j                         sydt        d t	        |      D              dz  z
  dz  }|d	v rt        |      |k(  S |d
v r||   |k(  S |dv r|t        |      ||   hv S dS )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.

    > *New in version 0.13.0*.
    r
   F
JABCDEFGHIr   r   r   
   c              3      K   | ]H  \  }}|d z  dk(  r.t        t        t        t        t        |      d z                    n
t        |       J yw)   r   N)summapr   str).0indexchars      r   	<genexpr>zes_cif.<locals>.<genexpr>E   sJ      
 t 27aCCSY]+,-SYN
s   AAABEHPSQW	CDFGJNRUV)r   r   r   r   	enumerater    )r   r   	first_chrdoi_bodycontrolress         r   es_cifr-      s    F CJ!OKKMEEaIQqzHAhG

 
  )2	
 
 	 		C F3x7""FSzW$$09[0H7s3xs,,SeSr   c                0    dddd}h d}t        | ||      S )a=  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')
        # Output: True
        >>> es_nif('26643189X')
        # Output: ValidationError(func=es_nif, 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.

    > *New in version 0.13.0*.
    0)LMK>   	00000000T	00000001R	X0000000Tr   )r   r   r   s      r   es_nifr7   T   s&    < !s5;Mu&6FFr   c                >    dddd}| r| d   |v rt        | |dh      S y)u2  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')
        # Output: True
        >>> es_nie('X0095892X')
        # Output: ValidationError(func=es_nie, 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.

    > *New in version 0.13.0*.
    r/   12)XYZr   r5   Fr6   )r   r   s     r   es_nier>   w   s5    < !s5q--"5*:[MJJr   c                L    t        |       xs t        |       xs t        |       S )a  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')
        # Output: True
        >>> es_doi('X0095892X')
        # Output: ValidationError(func=es_doi, 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.

    > *New in version 0.13.0*.
    )r>   r7   r-   )r   s    r   es_doir@      s     : %=:F5M:VE]:r   N)__doc__typingr   r   validators.utilsr   r    r   r-   r7   r>   r@    r   r   <module>rE      s      '
Fs 
Fd38n 
FUXY\U] 
F 9T# 9T 9Tx G# G GD !# ! !H ;# ; ;r   