Skip to content

fix(Validation): fix Discover Card prefix typo in CreditCardRules - #10810

Open
banghamid wants to merge 2 commits into
codeigniter4:developfrom
banghamid:fix/creditcard-discover-prefix
Open

banghamid wants to merge 2 commits into
codeigniter4:developfrom
banghamid:fix/creditcard-discover-prefix

Conversation

@banghamid

@banghamid banghamid commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Description
In system/Validation/CreditCardRules.php, the Discover Card prefix list contained a typo (656 instead of 646):

'Discover Card' => [
    'name'       => 'discover',
    'length'     => '16,19',
    'prefixes'   => '6011,622,644,645,656,647,648,649,65',
    'checkdigit' => true,
],

Discover IIN ranges officially include 6011, 622126–622925, 644–649, and 65.
In the prefix list, 656 was an apparent typo for 646 (leaving 646 missing, while 656 was already redundant with prefix 65). As a result, valid Discover card numbers starting with 646 were rejected by valid_cc_number.

Sources confirming Discover IIN prefix range 644–649 (including 646):

  • ISO/IEC 7812 & Discover Global Network IIN/BIN specifications allocate prefixes 6011, 622126–622925, 644–649, and 65 to the Discover Network.
  • Wikipedia: Payment card number - Issuer identification number (IIN)
  • Major payment gateways & card validator specifications (e.g., Stripe / Braintree Discover card regex: ^6(?:011|5[0-9]{2}|4[4-9][0-9]|22...)).

This PR:

  • Fixes the typo in CreditCardRules::$cardList['Discover Card']['prefixes'] from 656 to 646.
  • Adds regression test cases discover21 (16-digit 646*) and discover22 (19-digit 646*) in tests/system/Validation/StrictRules/CreditCardRulesTest.php (which also covers tests/system/Validation/CreditCardRulesTest.php).
  • Adds a changelog entry to docs/changelogs/v4.7.7.md.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@carson-codeigniter4 carson-codeigniter4 Bot added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 21, 2026

@michalsn michalsn left a comment

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.

This looks right. Could you provide a source confirming that 646 is a valid Discover prefix? Please also add a changelog entry.

@carson-codeigniter4 carson-codeigniter4 Bot added the needs template Opened issues not following the bug form template label Nov 22, 2026
@carson-codeigniter4

This comment has been minimized.

@banghamid

Copy link
Copy Markdown
Contributor Author

Thanks @michalsn!

1. Source for 646 as a valid Discover prefix

Discover's official Issuer Identification Number (IIN / BIN) range includes 6011, 622126–622925, 644–649 (all 6 prefixes: 644, 645, 646, 647, 648, 649), and 65:

  • ISO/IEC 7812 & Discover Global Network IIN specifications:
    The range 644000–649999 is officially allocated to the Discover Network.
  • Wikipedia: Payment card number (Issuer identification number):
    Lists Discover IIN ranges as 6011, 622126–622925, 644–649, and 65.
  • Payment processor specifications (Stripe, Braintree/PayPal):
    Standard regex for Discover cards uses ^6(?:011|5[0-9]{2}|4[4-9][0-9]|22...), where 64[4-9] explicitly matches the continuous block 644 through 649.

In the original array (6011,622,644,645,656,647,648,649,65), 656 was an apparent typo for 646 in the sequential block 644, 645, [646], 647, 648, 649 (656 was already redundant since 65 is present).

2. Changelog entry

I have added the changelog entry to docs/changelogs/v4.7.7.md and updated the PR body.

@carson-codeigniter4 carson-codeigniter4 Bot removed the needs template Opened issues not following the bug form template label Nov 22, 2026
@banghamid
banghamid requested a review from michalsn November 22, 2026 02:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants