feat(isCreditCard): add Maestro and InstaPayment card support#2671
feat(isCreditCard): add Maestro and InstaPayment card support#2671abhu85 wants to merge 1 commit intovalidatorjs:masterfrom
Conversation
Add validation support for: - Maestro cards (prefixes 5018, 5020, 5038, 6304, 6759, 6761, 6763) - InstaPayment cards (prefixes 637, 638, 639) Both card types are added as individual providers with proper tests. Rescues stale PR validatorjs#1701 (4.5 years old) by rebasing changes onto current code structure. The original PR used a single regex approach, but the codebase has since evolved to use individual provider regexes, so this implementation follows the current pattern. Original author: @avaly Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-Authored-By: avaly <3009556+avaly@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2671 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2592 2592
Branches 660 660
=========================================
Hits 2592 2592 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds support for validating Maestro and InstaPayment card numbers in the existing isCreditCard validator, aligning with the current per-provider cards regex approach.
Changes:
- Added
maestroandinstapaymentprovider regexes tosrc/lib/isCreditCard.js. - Extended general
isCreditCardtest cases to include representative valid/invalid numbers for the new providers. - Added provider-specific test blocks for Maestro and InstaPayment.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/lib/isCreditCard.js |
Adds new provider regexes so isCreditCard can validate Maestro and InstaPayment (with/without explicit provider). |
test/validators.test.js |
Adds provider-specific and general validation test cases for Maestro and InstaPayment numbers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| instapayment: /^63[7-9][0-9]{13}$/, | ||
| jcb: /^(?:2131|1800|35\d{3})\d{11}$/, | ||
| maestro: /^(5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15}$/, | ||
| mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/, // /^[25][1-7][0-9]{14}$/; | ||
| unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/, |
There was a problem hiding this comment.
New providers instapayment and maestro are now accepted by isCreditCard when options.provider is used, but the README’s isCreditCard documentation still lists only the previous providers. Please update the documented provider list to include these new options so API consumers can discover them and avoid “not a valid credit card provider” errors due to outdated docs.
Summary
Add credit card validation support for Maestro and InstaPayment card types.
Changes
maestrocard pattern toisCreditCard.jssupporting prefixes: 5018, 5020, 5038, 6304, 6759, 6761, 6763 (12-19 digits total)instapaymentcard pattern supporting prefixes: 637, 638, 639 (16 digits total)Background
This PR rescues the stale PR #1701 by @avaly (4.5 years old) which had merge conflicts.
The original PR used a single combined regex approach, but since then the codebase has evolved to use individual provider regexes in a
cardsobject. This implementation follows the current code pattern while preserving the original validation logic.Test Plan
Card Specifications
Maestro:
InstaPayment:
References
Co-Authored-By: avaly 3009556+avaly@users.noreply.github.com