ibantools-germany
Version:
IBAN Validator and Generator for German Bank Accounts
22 lines (21 loc) • 878 B
JavaScript
;
/**
* 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, [3, 1, 3, 1, 3, 1, 3, 1, 3]);
const unitDigits = (0, helper_1.getUnitsFromNumbers)(weightedDigits);
const sum = (0, helper_1.calculateSum)(unitDigits);
const unitDigit = (0, helper_1.getUnitFromNumber)(sum);
const calculatedCheckDigit = (0, helper_1.getUnitFromNumber)(10 - unitDigit);
if (givenCheckDigit === calculatedCheckDigit) {
return "VALID";
}
return "INVALID";
};