UNPKG

ibantools-germany

Version:

IBAN Validator and Generator for German Bank Accounts

21 lines (20 loc) 804 B
"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 }); const helper_1 = require("../helper"); exports.default = (number) => { const digits = (0, helper_1.getDigits)(number); const givenCheckDigit = digits.pop(); // Check digit is last digit const weightedDigits = (0, helper_1.weightDigitsRTL)(digits, [2, 1, 2, 1, 2, 1, 2, 1, 2]); const crossSums = (0, helper_1.calculateCrossSums)(weightedDigits); const sum = (0, helper_1.calculateSum)(crossSums); const calculatedCheckDigit = (0, helper_1.getUnitFromNumber)(sum); if (calculatedCheckDigit === givenCheckDigit) { return "VALID"; } return "INVALID"; };