
    j                         d Z ddlmZ ddlZddlZddlmZ ed             Zedej        e	e
f         fd            Zede	fd            ZdS )	zFrance.    )	lru_cacheN)	validatorc                  @    t          j        dt           j                  S )zSSN Pattern.zW^([1,2])\s(\d{2})\s(0[1-9]|1[0-2])\s(\d{2,3}|2[A,B])\s(\d{2,3})\s(\d{3})(?:\s(\d{2}))?$)recompileVERBOSE     U/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/validators/i18n/fr.py_ssn_patternr      s$     :	 	
	 	 	r
   valuec                     | sdS t          | t                    r(| dv rdS 	 t          |           } n# t          $ r Y dS w xY wd| cxk    odk    nc pd| cxk    odk    nc pd| cxk    od	k    nc S )
ac  Validate a french department number.

    Examples:
        >>> fr_department(20)  # can be an integer
        ValidationError(func=fr_department, args={'value': 20})
        >>> fr_department("20")
        ValidationError(func=fr_department, args={'value': '20'})
        >>> fr_department("971")  # Guadeloupe
        True
        >>> fr_department("00")
        ValidationError(func=fr_department, args={'value': '00'})
        >>> fr_department('2A')  # Corsica
        True
        >>> fr_department('2B')
        True
        >>> fr_department('2C')
        ValidationError(func=fr_department, args={'value': '2C'})

    Args:
        value:
            French department number to validate.

    Returns:
        (Literal[True]): If `value` is a valid french department number.
        (ValidationError): If `value` is an invalid french department number.
    F2A2BT         _   i  i  )
isinstancestrint
ValueError)r   s    r   fr_departmentr      s    8  u% L  4	JJEE 	 	 	55	GrU0000b0000GC54G4G4G4GC4G4G4G4GGs   1 
??c                    | sdS t          j        t                      |           }|sdS t          |                                          }|d         }|d         }|dk    rt          |          sdS |dS t          |          t          |d                   k    rdS |dv r|d	k    rd
nd|d<   t          d                    |dd                             }t          |          d|dz  z
  k    S )a  Validate a french Social Security Number.

    Each french citizen has a distinct Social Security Number.
    For more information see [French Social Security Number][1] (sadly unavailable in english).

    [1]: https://fr.wikipedia.org/wiki/Num%C3%A9ro_de_s%C3%A9curit%C3%A9_sociale_en_France

    Examples:
        >>> fr_ssn('1 84 12 76 451 089 46')
        True
        >>> fr_ssn('1 84 12 76 451 089')  # control key is optional
        True
        >>> fr_ssn('3 84 12 76 451 089 46')  # wrong gender number
        ValidationError(func=fr_ssn, args={'value': '3 84 12 76 451 089 46'})
        >>> fr_ssn('1 84 12 76 451 089 47')  # wrong control key
        ValidationError(func=fr_ssn, args={'value': '1 84 12 76 451 089 47'})

    Args:
        value:
            French Social Security Number string to validate.

    Returns:
        (Literal[True]): If `value` is a valid french Social Security Number.
        (ValidationError): If `value` is an invalid french Social Security Number.
    F   99NT   r   r   1918 a   )	r   matchr   listgroupsr   lenr   join)r   matchedr&   control_key
departmentdigitss         r   fr_ssnr-   C   s   6  uh|~~u--G u'..""##F*KJT-
";";ut
:#fQi..(( u\!! '$..DDDq	%%&&F{frk 233r
   )__doc__	functoolsr   r   typingvalidators.utilsr   r   Unionr   r   r   r-   r	   r
   r   <module>r3      s            				  ' & & & & &    $Hc3h/ $H $H $H $HN 34# 34 34 34 34 34 34r
   