Skip to content

Commit f830d59

Browse files
committed
Update Hipercard, Elo, Visa and JCB validation pattern'
1 parent 5a3a004 commit f830d59

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ composer.lock
66

77
/build
88
/vendor
9+
.idea/

src/CreditCard.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ class CreditCard
2929
'cvcLength' => array(3),
3030
'luhn' => true,
3131
),
32+
'hipercard' => array(
33+
'type' => 'hipercard',
34+
'pattern' => '/^(606282\d{10}(\d{3})?)|(3841\d{15})$/',
35+
'length' => array(13, 16, 19),
36+
'cvcLength' => array(3),
37+
'luhn' => true,
38+
),
39+
'elo' => array(
40+
'type' => 'elo',
41+
'pattern' => '/^(4011(7[89])?)|43(1274|8935)|45(1416|7393|76(31|32)?)|50(4175|6699|67[0-7][0-8]|9\d{3})|627780|636(297|368|369)|6500(3([1-3]|[5-9])|4\d{1}|5[01])|650(4(0[5-9]|[1-3]\d{1}|8[5-9]|9\d{1})|5([0-2]\d{1}|3[0-8]|4[1-9]|5\d{1}|[6-8]\d{1}|9[0-8])|7(0\d{1}|1[0-8]|2[0-7])|9(0[1-9]|1\d{1}|20))|6516(5[2-9]|6\d{1}|7[0-9])|6550([01]\d{1}|2[1-9]|[34]\d{1}|5[0-8])/',
42+
'length' => array(16),
43+
'cvcLength' => array(3),
44+
'luhn' => true,
45+
),
3246
'forbrugsforeningen' => array(
3347
'type' => 'forbrugsforeningen',
3448
'pattern' => '/^600/',
@@ -46,21 +60,21 @@ class CreditCard
4660
// Credit cards
4761
'hipercard' => array(
4862
'type' => 'hipercard',
49-
'pattern' => '/^(606282\d{10}(\d{3})?)|(3841\d{15})$/',
63+
'pattern' => '/^((606282|637095|637568)[0-9]{10}|38[0-9]{14,17})$/',
5064
'length' => array(13, 16, 19),
5165
'cvcLength' => array(3),
5266
'luhn' => true,
5367
),
5468
'elo' => array(
5569
'type' => 'elo',
56-
'pattern' => '/^(4011(7[89])?)|43(1274|8935)|45(1416|7393|76(31|32)?)|50(4175|6699|67[0-7][0-8]|9\d{3})|627780|636(297|368|369)|6500(3([1-3]|[5-9])|4\d{1}|5[01])|650(4(0[5-9]|[1-3]\d{1}|8[5-9]|9\d{1})|5([0-2]\d{1}|3[0-8]|4[1-9]|5\d{1}|[6-8]\d{1}|9[0-8])|7(0\d{1}|1[0-8]|2[0-7])|9(0[1-9]|1\d{1}|20))|6516(5[2-9]|6\d{1}|7[0-9])|6550([01]\d{1}|2[1-9]|[34]\d{1}|5[0-8])/',
70+
'pattern' => '/^((50670[7-8])|(506715)|(50671[7-9])|(50672[0-1])|(50672[4-9])|(50673[0-3])|(506739)|(50674[0-8])|(50675[0-3])|(50677[4-8])|(50900[0-9])|(50901[3-9])|(50902[0-9])|(50903[1-9])|(50904[0-9])|(50905[0-9])|(50906[0-4])|(50906[6-9])|(50907[0-2])|(50907[4-5])|(636368)|(636297)|(504175)|(438935)|(40117[8-9])|(45763[1-2])|(457393)|(431274)|(50907[6-9])|(50908[0-9])|(627780))/',
5771
'length' => array(16),
5872
'cvcLength' => array(3),
5973
'luhn' => true,
6074
),
6175
'visa' => array(
6276
'type' => 'visa',
63-
'pattern' => '/^4/',
77+
'pattern' => '/^4[0-9]{15}$/',
6478
'length' => array(13, 16),
6579
'cvcLength' => array(3),
6680
'luhn' => true,
@@ -103,7 +117,7 @@ class CreditCard
103117
),
104118
'jcb' => array(
105119
'type' => 'jcb',
106-
'pattern' => '/^35/',
120+
'pattern' => '/(3[0-9]{15}|(2131|1800)[0-9]{11})/',
107121
'length' => array(16),
108122
'cvcLength' => array(3),
109123
'luhn' => true,

0 commit comments

Comments
 (0)