Skip to content

visa() hardcodes 16 digits although Visa supports 19-digit PANs #556

Open

Description

@agammann

validators.visa() requires exactly 16 digits, but Visa supports 19-digit PANs. A 19-digit input with Visa's leading 4 and a valid Luhn checksum is rejected solely because of its length.

Reproduced with validators 0.36.0 at current master commit 22786cc6e7283a0fa452c179797e447f798db9f0 on Python 3.14.8:

from validators import card_number, visa

for value in ('4000000000000002', '4000000000000000006'):
    print(value, len(value), repr(card_number(value)), repr(visa(value)))

Observed:

4000000000000002 16 True True
4000000000000000006 19 True ValidationError(func=visa, args={'value': '4000000000000000006'})

These are synthetic structural test values, not issued card accounts. card_number() confirms that both pass the package's generic Luhn check.

Expected: visa() should not reject a Visa-format input just because it has 19 digits. Visa's public Transaction Acceptance Device Guide, section 2.1, discusses variable-length Visa PANs up to 19 digits.

The rejection comes from len(value) == 16 in src/validators/card.py:visa.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions