Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/validator/Constraints/CardSchemeValidator.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
25 * @see http://www.regular-expressions.info/creditcard.html | 25 * @see http://www.regular-expressions.info/creditcard.html |
26 * @see http://www.barclaycard.co.uk/business/files/Ranges_and_Rules_September_2014.pdf | 26 * @see http://www.barclaycard.co.uk/business/files/Ranges_and_Rules_September_2014.pdf |
27 */ | 27 */ |
28 class CardSchemeValidator extends ConstraintValidator | 28 class CardSchemeValidator extends ConstraintValidator |
29 { | 29 { |
30 protected $schemes = array( | 30 protected $schemes = [ |
31 // American Express card numbers start with 34 or 37 and have 15 digits. | 31 // American Express card numbers start with 34 or 37 and have 15 digits. |
32 'AMEX' => array( | 32 'AMEX' => [ |
33 '/^3[47][0-9]{13}$/', | 33 '/^3[47][0-9]{13}$/', |
34 ), | 34 ], |
35 // China UnionPay cards start with 62 and have between 16 and 19 digits. | 35 // China UnionPay cards start with 62 and have between 16 and 19 digits. |
36 // Please note that these cards do not follow Luhn Algorithm as a checksum. | 36 // Please note that these cards do not follow Luhn Algorithm as a checksum. |
37 'CHINA_UNIONPAY' => array( | 37 'CHINA_UNIONPAY' => [ |
38 '/^62[0-9]{14,17}$/', | 38 '/^62[0-9]{14,17}$/', |
39 ), | 39 ], |
40 // Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits. | 40 // Diners Club card numbers begin with 300 through 305, 36 or 38. All have 14 digits. |
41 // There are Diners Club cards that begin with 5 and have 16 digits. | 41 // There are Diners Club cards that begin with 5 and have 16 digits. |
42 // These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard. | 42 // These are a joint venture between Diners Club and MasterCard, and should be processed like a MasterCard. |
43 'DINERS' => array( | 43 'DINERS' => [ |
44 '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/', | 44 '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/', |
45 ), | 45 ], |
46 // Discover card numbers begin with 6011, 622126 through 622925, 644 through 649 or 65. | 46 // Discover card numbers begin with 6011, 622126 through 622925, 644 through 649 or 65. |
47 // All have 16 digits. | 47 // All have 16 digits. |
48 'DISCOVER' => array( | 48 'DISCOVER' => [ |
49 '/^6011[0-9]{12}$/', | 49 '/^6011[0-9]{12}$/', |
50 '/^64[4-9][0-9]{13}$/', | 50 '/^64[4-9][0-9]{13}$/', |
51 '/^65[0-9]{14}$/', | 51 '/^65[0-9]{14}$/', |
52 '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/', | 52 '/^622(12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|91[0-9]|92[0-5])[0-9]{10}$/', |
53 ), | 53 ], |
54 // InstaPayment cards begin with 637 through 639 and have 16 digits. | 54 // InstaPayment cards begin with 637 through 639 and have 16 digits. |
55 'INSTAPAYMENT' => array( | 55 'INSTAPAYMENT' => [ |
56 '/^63[7-9][0-9]{13}$/', | 56 '/^63[7-9][0-9]{13}$/', |
57 ), | 57 ], |
58 // JCB cards beginning with 2131 or 1800 have 15 digits. | 58 // JCB cards beginning with 2131 or 1800 have 15 digits. |
59 // JCB cards beginning with 35 have 16 digits. | 59 // JCB cards beginning with 35 have 16 digits. |
60 'JCB' => array( | 60 'JCB' => [ |
61 '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/', | 61 '/^(?:2131|1800|35[0-9]{3})[0-9]{11}$/', |
62 ), | 62 ], |
63 // Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits. | 63 // Laser cards begin with either 6304, 6706, 6709 or 6771 and have between 16 and 19 digits. |
64 'LASER' => array( | 64 'LASER' => [ |
65 '/^(6304|670[69]|6771)[0-9]{12,15}$/', | 65 '/^(6304|670[69]|6771)[0-9]{12,15}$/', |
66 ), | 66 ], |
67 // Maestro international cards begin with 675900..675999 and have between 12 and 19 digits. | 67 // Maestro international cards begin with 675900..675999 and have between 12 and 19 digits. |
68 // Maestro UK cards begin with either 500000..509999 or 560000..699999 and have between 12 and 19 digits. | 68 // Maestro UK cards begin with either 500000..509999 or 560000..699999 and have between 12 and 19 digits. |
69 'MAESTRO' => array( | 69 'MAESTRO' => [ |
70 '/^(6759[0-9]{2})[0-9]{6,13}$/', | 70 '/^(6759[0-9]{2})[0-9]{6,13}$/', |
71 '/^(50[0-9]{4})[0-9]{6,13}$/', | 71 '/^(50[0-9]{4})[0-9]{6,13}$/', |
72 '/^5[6-9][0-9]{10,17}$/', | 72 '/^5[6-9][0-9]{10,17}$/', |
73 '/^6[0-9]{11,18}$/', | 73 '/^6[0-9]{11,18}$/', |
74 ), | 74 ], |
75 // All MasterCard numbers start with the numbers 51 through 55. All have 16 digits. | 75 // All MasterCard numbers start with the numbers 51 through 55. All have 16 digits. |
76 // October 2016 MasterCard numbers can also start with 222100 through 272099. | 76 // October 2016 MasterCard numbers can also start with 222100 through 272099. |
77 'MASTERCARD' => array( | 77 'MASTERCARD' => [ |
78 '/^5[1-5][0-9]{14}$/', | 78 '/^5[1-5][0-9]{14}$/', |
79 '/^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})$/', | 79 '/^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})$/', |
80 ), | 80 ], |
81 // All Visa card numbers start with a 4 and have a length of 13, 16, or 19 digits. | 81 // All Visa card numbers start with a 4 and have a length of 13, 16, or 19 digits. |
82 'VISA' => array( | 82 'VISA' => [ |
83 '/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/', | 83 '/^4([0-9]{12}|[0-9]{15}|[0-9]{18})$/', |
84 ), | 84 ], |
85 ); | 85 ]; |
86 | 86 |
87 /** | 87 /** |
88 * Validates a creditcard belongs to a specified scheme. | 88 * Validates a creditcard belongs to a specified scheme. |
89 * | 89 * |
90 * @param mixed $value | 90 * @param mixed $value |