8000 bug #19316 [Validator] Added additional MasterCard range to the CardS… · symfony/symfony@b7ed32a · GitHub
[go: up one dir, main page]

Skip to content

Commit b7ed32a

Browse files
committed
bug #19316 [Validator] Added additional MasterCard range to the CardSchemeValidator (Dennis Væversted)
This PR was merged into the 2.7 branch. Discussion ---------- [Validator] Added additional MasterCard range to the CardSchemeValidator From October 2016 MasterCard will introduce a new card range, 222100 through 272099. See: https://www.mctestcards.com/ (click the help in top right) This implements the additional regex for validation to succeed, and some additional unit tests for this new range. | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 4d68f56 [Validator] Added additional MasterCard range to the CardSchemeValidator
2 parents b795cfa + 4d68f56 commit b7ed32a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Symfony/Component/Validator/Constraints/CardSchemeValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ class CardSchemeValidator extends ConstraintValidator
7474
'/^6[0-9]{11,18}$/',
7575
),
7676
// All MasterCard numbers start with the numbers 51 through 55. All have 16 digits.
77+
// October 2016 MasterCard numbers can also start with 222100 through 272099.
7778
'MASTERCARD' => array(
7879
'/^5[1-5][0-9]{14}$/',
80+
'/^2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12})$/',
7981
),
8082
// All Visa card numbers start with a 4. New cards have 16 digits. Old cards have 13.
8183
'VISA' => array(

src/Symfony/Component/Validator/Tests/Constraints/CardSchemeValidatorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public function getValidNumbers()
102102
array('MAESTRO', '6594371785970435599'),
103103
array('MASTERCARD', '5555555555554444'),
104104
array('MASTERCARD', '5105105105105100'),
105+
array('MASTERCARD', '2221005555554444'),
106+
array('MASTERCARD', '2230000000000000'),
107+
array('MASTERCARD', '2300000000000000'),
108+
array('MASTERCARD', '2699999999999999'),
109+
array('MASTERCARD', '2709999999999999'),
110+
array('MASTERCARD', '2720995105105100'),
105111
array('VISA', '4111111111111111'),
106112
array('VISA', '4012888888881881'),
107113
array('VISA', '4222222222222'),
@@ -129,6 +135,8 @@ public function getInvalidNumbers()
129135
array('AMEX', '000000000000', CardScheme::INVALID_FORMAT_ERROR), // a lone number
130136
array('DINERS', '3056930', CardScheme::INVALID_FORMAT_ERROR), // only first part of the number
131137
array('DISCOVER', '1117', CardScheme::INVALID_FORMAT_ERROR), // only last 4 digits
138+
array('MASTERCARD', '2721001234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
139+
array('MASTERCARD', '2220991234567890', CardScheme::INVALID_FORMAT_ERROR), // Not assigned yet
132140
);
133141
}
134142
}

0 commit comments

Comments
 (0)
0