diff --git a/src/Validators/CreditCard.php b/src/Validators/CreditCard.php index 7dbeb75b8..1c08690b4 100644 --- a/src/Validators/CreditCard.php +++ b/src/Validators/CreditCard.php @@ -60,7 +60,7 @@ self::AMERICAN_EXPRESS => '/^3[47]\d{13}$/', self::DINERS_CLUB => '/^3(?:0[0-5]|[68]\d)\d{11}$/', self::DISCOVER => '/^6(?:011|5\d{2})\d{12}$/', - self::JCB => '/^(?:2131|1800|35\d{3})\d{11}$/', + self::JCB => '/^(?:(?:2131|1800)\d{11}|35(?:2[89]|[3-8]\d)\d{12})$/', self::MASTERCARD => '/^(5[1-5]|2[2-7])\d{14}$/', self::VISA => '/^4\d{12}(?:\d{3})?$/', self::RUPAY => '/^6(?!011)(?:0[0-9]{14}|52[12][0-9]{12})$/', diff --git a/tests/unit/Validators/CreditCardTest.php b/tests/unit/Validators/CreditCardTest.php index b396f23ff..c7fec68b4 100644 --- a/tests/unit/Validators/CreditCardTest.php +++ b/tests/unit/Validators/CreditCardTest.php @@ -64,6 +64,8 @@ public static function providerForValidInput(): iterable [$discover, '6011000990139424'], [$general, '3566002020360505'], // JBC [$jcb, '3566002020360505'], + [$jcb, '3528000000000007'], // JCB 35 BIN Range lower bound + [$jcb, '3589000000000003'], // JCB 35 BIN Range upper bound [$general, '6522447005971501'], // RuPay [$rupay, '6062973831636410'], ]; @@ -94,6 +96,8 @@ public static function providerForInvalidInput(): iterable [$diners, '4012888888881881'], // Visa [$discover, '371449635398431'], // American Express [$jcb, '38520000023237'], // Diners Club + [$jcb, '3500000000000009'], // Luhn-valid, below the JCB 35 BIN Range (3528) + [$jcb, '3590000000000000'], // Luhn-valid, above the JCB 35 BIN Range (3589) [$master, '05105105105105100'], // Over-long (17-digit) Luhn-valid number; regression for missing ^ anchor ]; }