Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luhn Algorithm is not working as expected #1166

Closed
andreshndz opened this issue Jan 14, 2020 · 0 comments
Closed

Luhn Algorithm is not working as expected #1166

andreshndz opened this issue Jan 14, 2020 · 0 comments
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@andreshndz
Copy link
Contributor

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
@andreshndz andreshndz added the bug V1 Bug related to Pydantic V1.X label Jan 14, 2020
RajatRajdeep pushed a commit to RajatRajdeep/pydantic that referenced this issue May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

No branches or pull requests

2 participants