UNPKG

ibantools-germany

Version:

IBAN Validator and Generator for German Bank Accounts

26 lines (25 loc) 1.28 kB
"use strict"; /** * ibantools-germany * Copyright (c) 2022-2026 Markus Baumer <markus@baumer.dev> * SPDX-License-Identifier: MIT OR MPL-2.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.method33Core = void 0; const helper_1 = require("../helper"); const method06_1 = require("./method06"); const method33Core = (number, weights, modulo = 11, remainder0CheckDigit) => { const paddedNumber = (0, helper_1.paddedAccountNumber)(number); const digits = (0, helper_1.getDigits)(paddedNumber.slice(4, 10)); const givenCheckDigit = digits.pop(); // Check digit is last digit const weightedDigits = (0, helper_1.weightDigitsRTL)(digits, weights); const sum = (0, helper_1.calculateSum)(weightedDigits); const { difference: calculatedCheckDigit, remainder } = (0, helper_1.moduloDifference)(sum, modulo, modulo); // Special sub case used in method51dCore, method85, method87c if (remainder0CheckDigit !== undefined && remainder === 0) { return givenCheckDigit === remainder0CheckDigit ? "VALID" : "INVALID"; } return (0, method06_1.method06Result)(givenCheckDigit, calculatedCheckDigit); }; exports.method33Core = method33Core; exports.default = (number) => (0, exports.method33Core)(number, [2, 3, 4, 5, 6]);