Skip to content

feat(isCreditCard): add RuPay provider support - #2853

Open
Praddy2006 wants to merge 1 commit into
validatorjs:masterfrom
Praddy2006:feat/rupay-credit-card
Open

feat(isCreditCard): add RuPay provider support#2853
Praddy2006 wants to merge 1 commit into
validatorjs:masterfrom
Praddy2006:feat/rupay-credit-card

Conversation

@Praddy2006

Copy link
Copy Markdown

Closes #2829

Adds rupay as a supported provider value for isCreditCard, per the issue request.

Regex

rupay: /^(?
0-9
|60[6-8][0-9]{13})$/

Covers two BIN ranges independently confirmed against real observed BINs across multiple issuing banks:

  • 508xxx — confirmed via multiple independent BIN-lookup records (Union Bank, PNB, Bank of India, HDFC, Dhanlaxmi, Tamil Nadu State Apex Co-op Bank), all 16-digit RuPay cards.
  • 606xxx–608xxx — confirmed via BIN registry data plus independently observed real BINs.

Scope note

RuPay also issues co-branded cards using ranges already claimed by other schemes in this file — 65xx (Discover), 81xx (UnionPay), and 353xxx/356xxx (JCB). These are deliberately excluded here: those ranges belong to the partner network's own registered IIN blocks, so classifying them as rupay would misattribute numbering ownership and create ambiguous provider checks. Happy to revisit if maintainers want a different approach for co-branded cards.

Changes

  • src/lib/isCreditCard.js: added rupay pattern to the cards object
  • README.md: added rupay to the documented provider values
  • test/validators.test.js: added RuPay numbers to the general valid-card list, plus a dedicated provider: 'RuPay' test block (valid + invalid cases)

All test numbers are synthetic (correct BIN prefix + length + valid Luhn check digit) — no real card numbers used.

npm test passes locally: 324 passing, 100% statement/line/function coverage maintained.

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (a79ff98) to head (b44f85c).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2853   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2599           
  Branches       658       658           
=========================================
  Hits          2599      2599           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Praddy2006

Copy link
Copy Markdown
Author

Thanks for the visibility here — I want to flag something I should've caught before opening this: #2830 is already open on the same underlying issue (#2829), with @tux-tn having requested changes there on Jul 28.

I used an AI assistant to help research BIN coverage before opening this PR, and it caught the overlap. Sharing that analysis here for transparency:

Comparing this PR's regex against #2830's:

Both cover 606xxx–608xxx similarly, which matches the ranges @tux-tn asked for in review of #2830.
This PR adds 508xxx, sourced from bank-verified BINs (Union Bank, PNB, Bank of India, HDFC, Dhanlaxmi, TNSC Bank) rather than a single link.
Neither PR covers 502801, 627387, or 695047, which @tux-tn cited as gaps in #2830.

The bigger problem: I pulled BINTable's full RuPay listing, and it's not a handful of clean ranges — it's ~3,899 individually registered BINs across 78 pages, genuinely non-contiguous even within the 508xxx block. That means any hand-picked regex (mine included) will keep hitting "you're missing X" feedback until someone processes the full list systematically.

Given #2830 was opened first and already has maintainer engagement, I don't think it's right to compete with it. I'm going to close this PR and move this research over to #2830 instead, and offer to help build out a fuller BIN range set there if useful. Apologies for the duplicate — happy to redirect effort wherever's most useful.

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.

Add RuPay credit card validation

1 participant