mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
Change endpoint from persons to people
This commit is contained in:
88
backend/apis/nodejs/node_modules/validator/lib/util/algorithms.js
generated
vendored
Normal file
88
backend/apis/nodejs/node_modules/validator/lib/util/algorithms.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.iso7064Check = iso7064Check;
|
||||
exports.luhnCheck = luhnCheck;
|
||||
exports.reverseMultiplyAndSum = reverseMultiplyAndSum;
|
||||
exports.verhoeffCheck = verhoeffCheck;
|
||||
/**
|
||||
* Algorithmic validation functions
|
||||
* May be used as is or implemented in the workflow of other validators.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ISO 7064 validation function
|
||||
* Called with a string of numbers (incl. check digit)
|
||||
* to validate according to ISO 7064 (MOD 11, 10).
|
||||
*/
|
||||
function iso7064Check(str) {
|
||||
var checkvalue = 10;
|
||||
for (var i = 0; i < str.length - 1; i++) {
|
||||
checkvalue = (parseInt(str[i], 10) + checkvalue) % 10 === 0 ? 10 * 2 % 11 : (parseInt(str[i], 10) + checkvalue) % 10 * 2 % 11;
|
||||
}
|
||||
checkvalue = checkvalue === 1 ? 0 : 11 - checkvalue;
|
||||
return checkvalue === parseInt(str[10], 10);
|
||||
}
|
||||
|
||||
/*
|
||||
* Luhn (mod 10) validation function
|
||||
* Called with a string of numbers (incl. check digit)
|
||||
* to validate according to the Luhn algorithm.
|
||||
*/
|
||||
function luhnCheck(str) {
|
||||
var checksum = 0;
|
||||
var second = false;
|
||||
for (var i = str.length - 1; i >= 0; i--) {
|
||||
if (second) {
|
||||
var product = parseInt(str[i], 10) * 2;
|
||||
if (product > 9) {
|
||||
// sum digits of product and add to checksum
|
||||
checksum += product.toString().split('').map(function (a) {
|
||||
return parseInt(a, 10);
|
||||
}).reduce(function (a, b) {
|
||||
return a + b;
|
||||
}, 0);
|
||||
} else {
|
||||
checksum += product;
|
||||
}
|
||||
} else {
|
||||
checksum += parseInt(str[i], 10);
|
||||
}
|
||||
second = !second;
|
||||
}
|
||||
return checksum % 10 === 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reverse TIN multiplication and summation helper function
|
||||
* Called with an array of single-digit integers and a base multiplier
|
||||
* to calculate the sum of the digits multiplied in reverse.
|
||||
* Normally used in variations of MOD 11 algorithmic checks.
|
||||
*/
|
||||
function reverseMultiplyAndSum(digits, base) {
|
||||
var total = 0;
|
||||
for (var i = 0; i < digits.length; i++) {
|
||||
total += digits[i] * (base - i);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/*
|
||||
* Verhoeff validation helper function
|
||||
* Called with a string of numbers
|
||||
* to validate according to the Verhoeff algorithm.
|
||||
*/
|
||||
function verhoeffCheck(str) {
|
||||
var d_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]];
|
||||
var p_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]];
|
||||
|
||||
// Copy (to prevent replacement) and reverse
|
||||
var str_copy = str.split('').reverse().join('');
|
||||
var checksum = 0;
|
||||
for (var i = 0; i < str_copy.length; i++) {
|
||||
checksum = d_table[checksum][p_table[i % 8][parseInt(str_copy[i], 10)]];
|
||||
}
|
||||
return checksum === 0;
|
||||
}
|
17
backend/apis/nodejs/node_modules/validator/lib/util/assertString.js
generated
vendored
Normal file
17
backend/apis/nodejs/node_modules/validator/lib/util/assertString.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = assertString;
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function assertString(input) {
|
||||
var isString = typeof input === 'string' || input instanceof String;
|
||||
if (!isString) {
|
||||
var invalidType = _typeof(input);
|
||||
if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
|
||||
throw new TypeError("Expected a string but received a ".concat(invalidType));
|
||||
}
|
||||
}
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
14
backend/apis/nodejs/node_modules/validator/lib/util/includes.js
generated
vendored
Normal file
14
backend/apis/nodejs/node_modules/validator/lib/util/includes.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
var includes = function includes(arr, val) {
|
||||
return arr.some(function (arrVal) {
|
||||
return val === arrVal;
|
||||
});
|
||||
};
|
||||
var _default = exports.default = includes;
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
18
backend/apis/nodejs/node_modules/validator/lib/util/merge.js
generated
vendored
Normal file
18
backend/apis/nodejs/node_modules/validator/lib/util/merge.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = merge;
|
||||
function merge() {
|
||||
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
||||
for (var key in defaults) {
|
||||
if (typeof obj[key] === 'undefined') {
|
||||
obj[key] = defaults[key];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
20
backend/apis/nodejs/node_modules/validator/lib/util/multilineRegex.js
generated
vendored
Normal file
20
backend/apis/nodejs/node_modules/validator/lib/util/multilineRegex.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = multilineRegexp;
|
||||
/**
|
||||
* Build RegExp object from an array
|
||||
* of multiple/multi-line regexp parts
|
||||
*
|
||||
* @param {string[]} parts
|
||||
* @param {string} flags
|
||||
* @return {object} - RegExp object
|
||||
*/
|
||||
function multilineRegexp(parts, flags) {
|
||||
var regexpAsStringLiteral = parts.join('');
|
||||
return new RegExp(regexpAsStringLiteral, flags);
|
||||
}
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
21
backend/apis/nodejs/node_modules/validator/lib/util/toString.js
generated
vendored
Normal file
21
backend/apis/nodejs/node_modules/validator/lib/util/toString.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = toString;
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function toString(input) {
|
||||
if (_typeof(input) === 'object' && input !== null) {
|
||||
if (typeof input.toString === 'function') {
|
||||
input = input.toString();
|
||||
} else {
|
||||
input = '[object Object]';
|
||||
}
|
||||
} else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) {
|
||||
input = '';
|
||||
}
|
||||
return String(input);
|
||||
}
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
18
backend/apis/nodejs/node_modules/validator/lib/util/typeOf.js
generated
vendored
Normal file
18
backend/apis/nodejs/node_modules/validator/lib/util/typeOf.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = typeOf;
|
||||
/**
|
||||
* Better way to handle type checking
|
||||
* null, {}, array and date are objects, which confuses
|
||||
*/
|
||||
function typeOf(input) {
|
||||
var rawObject = Object.prototype.toString.call(input).toLowerCase();
|
||||
var typeOfRegex = /\[object (.*)]/g;
|
||||
var type = typeOfRegex.exec(rawObject)[1];
|
||||
return type;
|
||||
}
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
Reference in New Issue
Block a user