Skip to content

Reject non-ASCII digits in card numbers - #568

Open
Mrun25 wants to merge 2 commits into
python-validators:masterfrom
Mrun25:fix/non-ascii-card-digits
Open

Mrun25 wants to merge 2 commits into
python-validators:masterfrom
Mrun25:fix/non-ascii-card-digits

Conversation

@Mrun25

@Mrun25 Mrun25 commented Nov 14, 2026

Copy link
Copy Markdown

Fixes #567

Reject non-ASCII input before the Luhn check. Python's int() accepts Unicode decimal digits, so fully Arabic-Indic/full-width card numbers, and mixed strings with an ASCII issuer prefix, currently pass validation.

Adds 20 regression cases for fully non-ASCII input and mixed input across the generic validator and all eight card-brand helpers. Existing ASCII card numbers and invalid-checksum behavior stay unchanged.

Validation:

  • The 20 new cases fail on unchanged master and pass with the fix.
  • Full tox test suites on Python 3.11, 3.12, 3.13 and 3.14: 1,594 passed on each, including doctests and the optional crypto-address tests.
  • Tox lint, type, format and sast environments pass.
  • Exercised card_number() and visa() directly with valid ASCII, invalid checksum, Arabic-Indic, full-width and mixed input.

AI assistance was used for implementation and testing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

card_number() accepts non-ASCII Unicode digits (full-width, Arabic-Indic) as valid card numbers

1 participant