summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/node_modules/validator/lib/isCreditCard.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
committerRaindropsSys <contact@minteck.org>2023-04-06 22:18:28 +0200
commit83354b2b88218090988dd6e526b0a2505b57e0f1 (patch)
treee3c73c38a122a78bb7e66fbb99056407edd9d4b9 /includes/external/addressbook/node_modules/validator/lib/isCreditCard.js
parent47b8f2299a483024c4a6a8876af825a010954caa (diff)
downloadpluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.gz
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.tar.bz2
pluralconnect-83354b2b88218090988dd6e526b0a2505b57e0f1.zip
Updated 5 files and added 1110 files (automated)
Diffstat (limited to 'includes/external/addressbook/node_modules/validator/lib/isCreditCard.js')
-rw-r--r--includes/external/addressbook/node_modules/validator/lib/isCreditCard.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/includes/external/addressbook/node_modules/validator/lib/isCreditCard.js b/includes/external/addressbook/node_modules/validator/lib/isCreditCard.js
new file mode 100644
index 0000000..43df895
--- /dev/null
+++ b/includes/external/addressbook/node_modules/validator/lib/isCreditCard.js
@@ -0,0 +1,52 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = isCreditCard;
+
+var _assertString = _interopRequireDefault(require("./util/assertString"));
+
+var _isLuhnNumber = _interopRequireDefault(require("./isLuhnNumber"));
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var cards = {
+ amex: /^3[47][0-9]{13}$/,
+ dinersclub: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
+ discover: /^6(?:011|5[0-9][0-9])[0-9]{12,15}$/,
+ jcb: /^(?:2131|1800|35\d{3})\d{11}$/,
+ mastercard: /^5[1-5][0-9]{2}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}$/,
+ // /^[25][1-7][0-9]{14}$/;
+ unionpay: /^(6[27][0-9]{14}|^(81[0-9]{14,17}))$/,
+ visa: /^(?:4[0-9]{12})(?:[0-9]{3,6})?$/
+};
+/* eslint-disable max-len */
+
+var allCards = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/;
+/* eslint-enable max-len */
+
+function isCreditCard(card) {
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+ (0, _assertString.default)(card);
+ var provider = options.provider;
+ var sanitized = card.replace(/[- ]+/g, '');
+
+ if (provider && provider.toLowerCase() in cards) {
+ // specific provider in the list
+ if (!cards[provider.toLowerCase()].test(sanitized)) {
+ return false;
+ }
+ } else if (provider && !(provider.toLowerCase() in cards)) {
+ /* specific provider not in the list */
+ throw new Error("".concat(provider, " is not a valid credit card provider."));
+ } else if (!allCards.test(sanitized)) {
+ // no specific provider
+ return false;
+ }
+
+ return (0, _isLuhnNumber.default)(card);
+}
+
+module.exports = exports.default;
+module.exports.default = exports.default; \ No newline at end of file