Skip to content

Support for 13/19 digits VISA credit cards in PaymentCardNumber type #1416

@Bahus

Description

@Bahus

Feature Request

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

             pydantic version: 1.5
            pydantic compiled: True
                 install path: /Users/<hidden>/.pyenv/versions/3.7.2/envs/common-utils/lib/python3.7/site-packages/pydantic
               python version: 3.7.2 (default, Jan 22 2020, 18:22:02)  [Clang 10.0.1 (clang-1001.0.46.4)]
                     platform: Darwin-18.7.0-x86_64-i386-64bit
     optional deps. installed: ['typing-extensions']

Currently PaymentCardNumber type does support 16-digits VISA only:

https://github.com/samuelcolvin/pydantic/blob/3cd8b1ee2d5aac76528dbe627f40fe1c27bf59f6/pydantic/types.py#L677-L679

However as described on wiki page https://en.wikipedia.org/wiki/Payment_card_number:

While the vast majority of Visa's account ranges describe 16 digit card numbers there are still a few account ranges (forty as of 11 December 2013) dedicated to 13 digit PANs and several (439 as of 11 Dec. 2013) account ranges where the issuer can mix 13 and 16 digit card numbers. Visa's VPay brand can specify PAN lengths from 13 to 19 digits and so card numbers of more than 16 digits are now being seen.

This fact is handler properly in faker library:

https://github.com/joke2k/faker/blob/0f86b60178fbbd27d50a184e94c429d4b60d8aef/faker/providers/credit_card/__init__.py#L48-L49

But not handled in pydantic.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions