UNPKG

ibantools-germany

Version:

IBAN Validator and Generator for German Bank Accounts

50 lines (47 loc) 1.89 kB
"use strict"; /** * ibantools-germany * Copyright (C) 2022-2024 Markus Baumer <markus@baumer.dev> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const method20_1 = __importDefault(require("./method20")); const method52_1 = require("./method52"); const eser9 = (number, blz) => { if (number.length !== 9) { return null; } const blz56 = blz.slice(4, 6); const number2 = number.slice(1, 2); const blz8 = blz.slice(7, 8); const number1 = number.slice(0, 1); const number3 = number.slice(2, 3); const number4Rest = number.slice(3, 9).replace(/^0+/, ""); return `${blz56}${number2}${blz8}${number1}${number3}${number4Rest}`; }; exports.default = (number, blz) => { if (number.length === 10 && number.match(/^9/)) { return (0, method20_1.default)(number); } if (blz.length != 8 || !blz.match(/^\d{3}5/)) { return "INVALID"; } const eserAccount = eser9(number.slice(-9), blz); if (!eserAccount) { return "INVALID"; } return (0, method52_1.eserValidate)(eserAccount); };