card¶
- validators.card.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'})
- Parameters:
value – American Express card number string to validate
- Returns:
If value is a valid American Express card number. (ValidationError): If value is an invalid American Express card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – Generic card number string to validate
- Returns:
If value is a valid generic card number. (ValidationError): If value is an invalid generic card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – Diners Club card number string to validate
- Returns:
If value is a valid Diners Club card number. (ValidationError): If value is an invalid Diners Club card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – Discover card number string to validate
- Returns:
If value is a valid Discover card number. (ValidationError): If value is an invalid Discover card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – JCB card number string to validate
- Returns:
If value is a valid JCB card number. (ValidationError): If value is an invalid JCB card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – Mastercard card number string to validate
- Returns:
If value is a valid Mastercard card number. (ValidationError): If value is an invalid Mastercard card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – Mir card number string to validate.
- Returns:
If value is a valid Mir card number. (ValidationError): If value is an invalid Mir card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – UnionPay card number string to validate
- Returns:
If value is a valid UnionPay card number. (ValidationError): If value is an invalid UnionPay card number.
- Return type:
(Literal[True])
- validators.card.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'})
- Parameters:
value – Visa card number string to validate
- Returns:
If value is a valid Visa card number. (ValidationError): If value is an invalid Visa card number.
- Return type:
(Literal[True])