-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcards.js
97 lines (95 loc) · 1.59 KB
/
cards.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
var defaultFormat = /(\d{1,4})/g;
var cards = [
// # Debit cards must come first, since they have more
// # specific patterns than their credit-card equivalents.
{
type: 'visaelectron',
pattern: /^4(026|17500|405|508|844|91[37])/,
format: defaultFormat,
length: [16],
cvcLength: [3],
luhn: true
},
{
type: 'maestro',
pattern: /^(5(018|0[23]|[68])|6(39|7))/,
format: defaultFormat,
length: [12, 13, 14, 15, 16, 17, 18, 19],
cvcLength: [3],
luhn: true
},
{
type: 'forbrugsforeningen',
pattern: /^600/,
format: defaultFormat,
length: [16],
cvcLength: [3],
luhn: true
},
{
type: 'dankort',
pattern: /^5019/,
format: defaultFormat,
length: [16],
cvcLength: [3],
luhn: true
},
// # Credit cards
{
type: 'visa',
pattern: /^4/,
format: defaultFormat,
length: [13, 16],
cvcLength: [3],
luhn: true
},
{
type: 'mastercard',
pattern: /^5[0-5]/,
format: defaultFormat,
length: [16],
cvcLength: [3],
luhn: true
},
{
type: 'amex',
pattern: /^3[47]/,
format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
length: [15],
cvcLength: [3, 4],
luhn: true
},
{
type: 'dinersclub',
pattern: /^3[0689]/,
format: defaultFormat,
length: [14],
cvcLength: [3],
luhn: true
},
{
type: 'discover',
pattern: /^6([045]|22)/,
format: defaultFormat,
length: [16],
cvcLength: [3],
luhn: true
},
{
type: 'unionpay',
pattern: /^(62|88)/,
format: defaultFormat,
length: [16, 17, 18, 19],
cvcLength: [3],
luhn: false
},
{
type: 'jcb',
pattern: /^35/,
format: defaultFormat,
length: [16],
cvcLength: [3],
luhn: true
}
];
module.exports = cards;