checkdigit.luhn.validate

checkdigit.luhn.validate(data: str) bool[source]

Validates a luhn check digit.

Parameters:

data – A string of characters representing a full luhn code

Returns:

A boolean representing whether the check digit validates the data or not

Return type:

bool

Examples

>>> from checkdigit import luhn
>>> luhn.validate("541756116585277")
True
>>> luhn.validate("79927398713")
True
>>> luhn.validate("49927398717")
False
>>> luhn.validate("1234567812345678")
False