Skip to content

feat(isCreditCard): add Maestro and InstaPayment card support#2671

Open
abhu85 wants to merge 1 commit intovalidatorjs:masterfrom
abhu85:rescue/maestro-cards-1701
Open

feat(isCreditCard): add Maestro and InstaPayment card support#2671
abhu85 wants to merge 1 commit intovalidatorjs:masterfrom
abhu85:rescue/maestro-cards-1701

Conversation

@abhu85
Copy link
Copy Markdown

@abhu85 abhu85 commented Mar 2, 2026

Summary

Add credit card validation support for Maestro and InstaPayment card types.

Changes

  • Add maestro card pattern to isCreditCard.js supporting prefixes: 5018, 5020, 5038, 6304, 6759, 6761, 6763 (12-19 digits total)
  • Add instapayment card pattern supporting prefixes: 637, 638, 639 (16 digits total)
  • Add provider-specific tests for both card types with valid Luhn numbers
  • Add test cases to general isCreditCard validation

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 cards object. This implementation follows the current code pattern while preserving the original validation logic.

Test Plan

  • All 319 existing tests pass
  • 100% code coverage maintained
  • Linting passes
  • Test numbers validated with Luhn algorithm

Card Specifications

Maestro:

InstaPayment:

References


Co-Authored-By: avaly 3009556+avaly@users.noreply.github.com

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
Copy link
Copy Markdown

codecov bot commented Mar 2, 2026

Codecov Report

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

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.
📢 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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 maestro and instapayment provider regexes to src/lib/isCreditCard.js.
  • Extended general isCreditCard test 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.

Comment on lines +8 to 12
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}))$/,
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abhu85 fix this

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.

3 participants