Skip to content

Luhn Algorithm is not working as expected #1166

@andreshndz

Description

@andreshndz

Bug

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.3
            pydantic compiled: False
                 install path: /Users/andreshernandez/Desktop/git/pydantic/pydantic
               python version: 3.7.5 (default, Nov  1 2019, 02:16:32)  [Clang 11.0.0 (clang-1100.0.33.8)]
                     platform: Darwin-18.2.0-x86_64-i386-64bit
     optional deps. installed: ['typing-extensions', 'email-validator', 'devtools']
from pydantic.types import PaymentCardNumber

card_number = '4951486642583068'  # luhn valid
PaymentCardNumber(card_number).validate_luhn_check_digit(card_number)

Throws a LuhnValidationError:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pydantic/types.py", line 657, in validate_luhn_check_digit
    raise errors.LuhnValidationError
pydantic.errors.LuhnValidationError: card number is not luhn valid

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions