
    Ii                         S r SSKrSSKJr  \S\4S j5       r\S\4S j5       r\S\4S j5       r\S\4S	 j5       r\S\4S
 j5       r	\S\4S j5       r
\S\4S j5       r\S\4S j5       rg)zCard.    N   )	validatorvaluec                    U (       d  g [        [        [        U 5      5      n[        USSS2   5      n[        S USSS2    5       5      nX#-   S-  S:H  $ ! [         a     gf = f)a1  Return whether or not given value is a valid generic card number.

This validator is based on [Luhn's algorithm][1].

[1]: https://github.com/mmcloughlin/luhn

Examples:
    >>> card_number('4242424242424242')
    # Output: True
    >>> card_number('4242424242424241')
    # Output: ValidationError(func=card_number, args={'value': '4242424242424241'})

Args:
    value:
        Generic card number string to validate

Returns:
    (Literal[True]): If `value` is a valid generic card number.
    (ValidationError): If `value` is an invalid generic card number.
FNc              3   R   #    U  H  n[        [        S U-  S5      5      v   M     g7f)   
   N)sumdivmod).0ds     5/venv/lib/python3.13/site-packages/validators/card.py	<genexpr>card_number.<locals>.<genexpr>%   s#     F~!s6!a%,--~s   %'r   r   )listmapintr   
ValueError)r   digitsodd_sumeven_sums       r   card_numberr   
   sr    , c#uo&fRVVn%Fvbf"f~FF"b(A-- s   AA 
A#"A#c                    [         R                  " S5      n[        U 5      =(       a&    [        U 5      S:H  =(       a    UR	                  U 5      $ )a  Return whether or not given value is a valid Visa card number.

Examples:
    >>> visa('4242424242424242')
    # Output: True
    >>> visa('2223003122003222')
    # Output: ValidationError(func=visa, args={'value': '2223003122003222'})

Args:
    value:
        Visa card number string to validate

Returns:
    (Literal[True]): If `value` is a valid Visa card number.
    (ValidationError): If `value` is an invalid Visa card number.
z^4   recompiler   lenmatchr   patterns     r   visar$   +   s9    $ jjGuK#e*"2Kw}}U7KK    c                    [         R                  " S5      n[        U 5      =(       a&    [        U 5      S:H  =(       a    UR	                  U 5      $ )a  Return whether or not given value is a valid Mastercard card number.

Examples:
    >>> mastercard('5555555555554444')
    # Output: True
    >>> mastercard('4242424242424242')
    # Output: ValidationError(func=mastercard, args={'value': '4242424242424242'})

Args:
    value:
        Mastercard card number string to validate

Returns:
    (Literal[True]): If `value` is a valid Mastercard card number.
    (ValidationError): If `value` is an invalid Mastercard card number.
z#^(51|52|53|54|55|22|23|24|25|26|27)r   r   r"   s     r   
mastercardr'   A   s:    $ jj?@GuK#e*"2Kw}}U7KKr%   c                    [         R                  " S5      n[        U 5      =(       a&    [        U 5      S:H  =(       a    UR	                  U 5      $ )a  Return whether or not given value is a valid American Express card number.

Examples:
    >>> amex('378282246310005')
    # Output: True
    >>> amex('4242424242424242')
    # Output: ValidationError(func=amex, args={'value': '4242424242424242'})

Args:
    value:
        American Express card number string to validate

Returns:
    (Literal[True]): If `value` is a valid American Express card number.
    (ValidationError): If `value` is an invalid American Express card number.
z^(34|37)   r   r"   s     r   amexr*   W   s9    $ jj%GuK#e*"2Kw}}U7KKr%   c                    [         R                  " S5      n[        U 5      =(       a&    [        U 5      S:H  =(       a    UR	                  U 5      $ )a  Return whether or not given value is a valid UnionPay card number.

Examples:
    >>> unionpay('6200000000000005')
    # Output: True
    >>> unionpay('4242424242424242')
    # Output: ValidationError(func=unionpay, args={'value': '4242424242424242'})

Args:
    value:
        UnionPay card number string to validate

Returns:
    (Literal[True]): If `value` is a valid UnionPay card number.
    (ValidationError): If `value` is an invalid UnionPay card number.
z^62r   r   r"   s     r   unionpayr,   m   9    $ jj GuK#e*"2Kw}}U7KKr%   c                    [         R                  " S5      n[        U 5      =(       a&    [        U 5      S;   =(       a    UR	                  U 5      $ )a  Return whether or not given value is a valid Diners Club card number.

Examples:
    >>> diners('3056930009020004')
    # Output: True
    >>> diners('4242424242424242')
    # Output: ValidationError(func=diners, args={'value': '4242424242424242'})

Args:
    value:
        Diners Club card number string to validate

Returns:
    (Literal[True]): If `value` is a valid Diners Club card number.
    (ValidationError): If `value` is an invalid Diners Club card number.
z^(30|36|38|39)>      r   r   r"   s     r   dinersr0      s:    $ jj*+GuQ#e*"8QW]]5=QQr%   c                    [         R                  " S5      n[        U 5      =(       a&    [        U 5      S:H  =(       a    UR	                  U 5      $ )a  Return whether or not given value is a valid JCB card number.

Examples:
    >>> jcb('3566002020360505')
    # Output: True
    >>> jcb('4242424242424242')
    # Output: ValidationError(func=jcb, args={'value': '4242424242424242'})

Args:
    value:
        JCB card number string to validate

Returns:
    (Literal[True]): If `value` is a valid JCB card number.
    (ValidationError): If `value` is an invalid JCB card number.
z^35r   r   r"   s     r   jcbr2      r-   r%   c                    [         R                  " S5      n[        U 5      =(       a&    [        U 5      S:H  =(       a    UR	                  U 5      $ )a  Return whether or not given value is a valid Discover card number.

Examples:
    >>> discover('6011111111111117')
    # Output: True
    >>> discover('4242424242424242')
    # Output: ValidationError(func=discover, args={'value': '4242424242424242'})

Args:
    value:
        Discover card number string to validate

Returns:
    (Literal[True]): If `value` is a valid Discover card number.
    (ValidationError): If `value` is an invalid Discover card number.
z^(60|64|65)r   r   r"   s     r   discoverr4      s9    $ jj(GuK#e*"2Kw}}U7KKr%   )__doc__r   utilsr   strr   r$   r'   r*   r,   r0   r2   r4    r%   r   <module>r9      s     
  s  @ L L L* Lc L L* L L L* LC L L* R# R R* Ls L L* LC L Lr%   