Initial commit
This commit is contained in:
commit
d7af9332c1
1674 changed files with 119641 additions and 0 deletions
52
node_modules/validator/lib/isISIN.js
generated
vendored
Normal file
52
node_modules/validator/lib/isISIN.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isISIN;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;
|
||||
|
||||
function isISIN(str) {
|
||||
(0, _assertString.default)(str);
|
||||
|
||||
if (!isin.test(str)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var checksumStr = str.replace(/[A-Z]/g, function (character) {
|
||||
return parseInt(character, 36);
|
||||
});
|
||||
var sum = 0;
|
||||
var digit;
|
||||
var tmpNum;
|
||||
var shouldDouble = true;
|
||||
|
||||
for (var i = checksumStr.length - 2; i >= 0; i--) {
|
||||
digit = checksumStr.substring(i, i + 1);
|
||||
tmpNum = parseInt(digit, 10);
|
||||
|
||||
if (shouldDouble) {
|
||||
tmpNum *= 2;
|
||||
|
||||
if (tmpNum >= 10) {
|
||||
sum += tmpNum + 1;
|
||||
} else {
|
||||
sum += tmpNum;
|
||||
}
|
||||
} else {
|
||||
sum += tmpNum;
|
||||
}
|
||||
|
||||
shouldDouble = !shouldDouble;
|
||||
}
|
||||
|
||||
return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10;
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
Loading…
Add table
Add a link
Reference in a new issue