Skip to content

Add New Card Preference Not Accepted Due to Pattern Conflict #128

@Touseef-ahmad

Description

@Touseef-ahmad

General information

  • Library version: 10.0.0

Issue description

When trying to add a new card that has the same starting digit (pattern) as a Visa card, the card-validator library identifies it as a Visa card. This results in the new card being rejected because the card lengths defined for Visa (16, 18, or 19 digits) do not match the length of the new card (e.g., 13 digits).

Steps to reproduce

Attempt to add a new card with a specific pattern (e.g., starting with 4) and a length of 13 digits.

const NEW_VISA_CARD = {
  niceType: 'new-Visa',
  type: 'new-visa',
  patterns: [4],
  gaps: [4, 8, 12],
  lengths: [13],
  code: {
    name: 'CVV',
    size: 3,
  },
};
valid.creditCardType.addCard(NEW_VISA_CARD);

The library incorrectly identifies the card as a Visa card.

const cardValidation = valid.number(<13-digit-number>);

The new card is identified as Visa card and not new-visa due to pattern conflict and the card is rejected.

Expected Behavior:

The library should distinguish between card types more effectively, allowing the addition of new cards with lengths and patterns that may conflict with existing card types like Visa.

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