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

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

Open
Touseef-ahmad opened this issue Oct 8, 2024 · 0 comments
Open

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

Touseef-ahmad opened this issue Oct 8, 2024 · 0 comments

Comments

@Touseef-ahmad
Copy link

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.

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

No branches or pull requests

1 participant