JFIF ( %!1"%)-...383.7(-.+  -%&--------------------------------------------------"J !1"AQaq2BR#r3Sbs4T$Dd(!1"2AQaq# ?q& JX"-` Es?Bl 1( H6fX[vʆEiB!j{hu85o%TI/*T `WTXط8%ɀt*$PaSIa9gkG$t h&)ٞ)O.4uCm!w*:K*I&bDl"+ ӹ=<Ӷ|FtI{7_/,/T ̫ԷC ȷMq9[1w!R{ U<?СCԀdc8'124,I'3-G s4IcWq$Ro瓩!"j']VӤ'B4H8n)iv$Hb=B:B=YݚXZILcA g$ΕzuPD? !զIEÁ $D'l"gp`+6֏$1Ľ˫EjUpܣvDت\2Wڰ_iIْ/~'cŧE:ɝBn9&rt,H`*Tf֙LK$#d "p/n$J oJ@'I0B+NRwj2GH.BWLOiGP W@#"@ę| 2@P D2[Vj!VE11pHn,c~T;U"H㤑EBxHClTZ7:х5,w=.`,:Lt1tE9""@pȠb\I_IƝpe &܏/ 3, WE2aDK &cy(3nI7'0W էΠ\&@:נ!oZIܻ1j@=So LJ{5UĜiʒP H{^iaH?U2j@<'13nXkdP&%ɰ&-(<]Vlya7 6c1HJcmǸ!˗GB3Ԏߏ\=qIPNĉA)JeJtEJbIxWbdóT V'0 WH*|D u6ӈHZh[8e  $v>p!rIWeB,i '佧 )g#[)m!tahm_<6nL/ BcT{"HSfp7|ybi8'.ih%,wm  403WebShell
403Webshell
Server IP : 88.223.91.91  /  Your IP : 216.73.217.26
Web Server : LiteSpeed
System : Linux id-dci-web1986.main-hosting.eu 5.14.0-611.26.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 29 05:24:47 EST 2026 x86_64
User : u686484674 ( 686484674)
PHP Version : 8.0.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python311/lib/python3.11/site-packages/validators/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python311/lib/python3.11/site-packages/validators//card.py
"""Card."""

# standard
import re

# local
from .utils import validator


@validator
def card_number(value: str, /):
    """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')
        True
        >>> card_number('4242424242424241')
        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.
    """
    if not value:
        return False
    try:
        digits = list(map(int, value))
        odd_sum = sum(digits[-1::-2])
        even_sum = sum(sum(divmod(2 * d, 10)) for d in digits[-2::-2])
        return (odd_sum + even_sum) % 10 == 0
    except ValueError:
        return False


@validator
def visa(value: str, /):
    """Return whether or not given value is a valid Visa card number.

    Examples:
        >>> visa('4242424242424242')
        True
        >>> visa('2223003122003222')
        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.
    """
    pattern = re.compile(r"^4")
    return card_number(value) and len(value) == 16 and pattern.match(value)


@validator
def mastercard(value: str, /):
    """Return whether or not given value is a valid Mastercard card number.

    Examples:
        >>> mastercard('5555555555554444')
        True
        >>> mastercard('4242424242424242')
        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.
    """
    pattern = re.compile(r"^(51|52|53|54|55|22|23|24|25|26|27)")
    return card_number(value) and len(value) == 16 and pattern.match(value)


@validator
def amex(value: str, /):
    """Return whether or not given value is a valid American Express card number.

    Examples:
        >>> amex('378282246310005')
        True
        >>> amex('4242424242424242')
        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.
    """
    pattern = re.compile(r"^(34|37)")
    return card_number(value) and len(value) == 15 and pattern.match(value)


@validator
def unionpay(value: str, /):
    """Return whether or not given value is a valid UnionPay card number.

    Examples:
        >>> unionpay('6200000000000005')
        True
        >>> unionpay('4242424242424242')
        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.
    """
    pattern = re.compile(r"^62")
    return card_number(value) and len(value) == 16 and pattern.match(value)


@validator
def diners(value: str, /):
    """Return whether or not given value is a valid Diners Club card number.

    Examples:
        >>> diners('3056930009020004')
        True
        >>> diners('4242424242424242')
        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.
    """
    pattern = re.compile(r"^(30|36|38|39)")
    return card_number(value) and len(value) in {14, 16} and pattern.match(value)


@validator
def jcb(value: str, /):
    """Return whether or not given value is a valid JCB card number.

    Examples:
        >>> jcb('3566002020360505')
        True
        >>> jcb('4242424242424242')
        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.
    """
    pattern = re.compile(r"^35")
    return card_number(value) and len(value) == 16 and pattern.match(value)


@validator
def discover(value: str, /):
    """Return whether or not given value is a valid Discover card number.

    Examples:
        >>> discover('6011111111111117')
        True
        >>> discover('4242424242424242')
        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.
    """
    pattern = re.compile(r"^(60|64|65)")
    return card_number(value) and len(value) == 16 and pattern.match(value)


@validator
def mir(value: str, /):
    """Return whether or not given value is a valid Mir card number.

    Examples:
        >>> mir('2200123456789019')
        True
        >>> mir('4242424242424242')
        ValidationError(func=mir, args={'value': '4242424242424242'})

    Args:
        value:
            Mir card number string to validate.

    Returns:
        (Literal[True]): If `value` is a valid Mir card number.
        (ValidationError): If `value` is an invalid Mir card number.
    """
    pattern = re.compile(r"^(220[0-4])")
    return card_number(value) and len(value) == 16 and pattern.match(value)

Youez - 2016 - github.com/yon3zu
LinuXploit