Implementation of ISO 13616-1:2020 - International Bank Account Number
The ISO 13616 package is a scoped package, which means one needs to provide the scope (both in installation and use).
$ npm install --save @konfirm/iso13616
As a version 3.0 the ISO 13616 package has full support for Typescript types and ES Modules.
For CommonJS (require
) users the packages has a breaking change as it not longer supports the [Symbol.match]
syntax for matching, please update to use ISO13616.match
instead
The ISO 13616 package implements the validation and generation of both the checksum and the full ISO 13616 value for any input
The validate method validates the provided value and determines whether it is a valid ISO 13616 value
argument | type | description |
---|---|---|
input | string or number |
The ISO 13616 to validate |
import { validate } from '@konfirm/iso13616';
console.log(validate('foo')); // false
console.log(validate('AD 97 82732793347266899771')); // true
const { validate } = require('@konfirm/iso13616');
console.log(validate('foo')); // false
console.log(validate('CA 02 0131 3167 8000 0065 1238 8')); // true
import { validate } from '@konfirm/iso13616';
console.log(validate('foo')); // false
console.log(validate('BY 13 NBRB 3600 900000002Z00AB00')); // true
The checksum method calculates the checksum for the provided account and country values. As per ISO13616-1:2020 the checksum will be in the range 02-98
.
NOTE, versions prior to 2.0 incorrectly used the character range 03-99
argument | type | description |
---|---|---|
account | string or number |
The account number (BBAN, Basic Bank Account Number) |
country | string |
The ISO 3166 country code |
import { checksum } from '@konfirm/iso13616';
console.log(checksum('0131 3167 8000 0065 1238 8', 'CA')); // '02'
const { checksum } = require('@konfirm/iso13616');
console.log(checksum('117 73016 1111101800000000', 'HU')); // '42'
import { checksum } from '@konfirm/iso13616';
console.log(checksum('X 05428 11101 000000123456', 'IT')); // '60'
The generate method generates the full ISO 13616 value for the provided account and country values, optionally formatted in pairs of four characters.
argument | type | default | description |
---|---|---|---|
account | string or number |
The account number (BBAN, Basic Bank Account Number) | |
country | string |
The ISO 3166 country code | |
format | boolean |
false |
Format the output in pairs of four |
import { generate } import '@konfirm/iso13616';
console.log(generate('CENR 00000000000000700025', 'SV')); // 'SV62CENR00000000000000700025'
console.log(generate('CENR 00000000000000700025', 'SV', true)); // 'SV62 CENR 0000 0000 0000 0070 0025'
const { generate } = require('@konfirm/iso13616');
console.log(generate('NBRB 3600 900000002Z00AB00', 'BY')); // 'BY13NBRB3600900000002Z00AB00'
console.log(generate('NBRB 3600 900000002Z00AB00', 'BY', true)); // 'BY13 NBRB 3600 9000 0000 2Z00 AB00'
import { generate } import '@konfirm/iso13616';
console.log(generate('123412341234', 'BI')); // 'BI33123412341234'
console.log(generate('123412341234', 'BI', true)); // 'BI33 1234 1234 1234'
Format the provided value in pairs of four characters
argument | type | description |
---|---|---|
input | string or number |
The ISO 13616 to format |
import { format } from '@konfirm/iso13616';
console.log(format('ab-cd12')); // 'ABCD 12'
const { format } = require('@konfirm/iso13616');
console.log(format('ab-cd-12 ')); // 'ABCD 12'
import { format } from '@konfirm/iso13616';
console.log(format('ab.cd 12')); // 'ABCD 12'
Match the input and return an object containing the matched country, checksum, account
argument | type | description |
---|---|---|
input | string or number |
The ISO 13616 to validate |
import { match } = from '@konfirm/iso13616';
console.log(match('AT 61 19043 00234573201'));
// { country: 'AT', checksum: '61', account: '1904300234573201' }
const { country, account, checksum } = match('AT 61 19043 00234573201');
console.log(country); // 'AT'
console.log(account); // '1904300234573201'
console.log(checksum); // '61'
const { match } = require('@konfirm/iso13616');
console.log(match('AT 61 19043 00234573201'));
// { country: 'AT', checksum: '61', account: '1904300234573201' }
const { country, account, checksum } = match('AT 61 19043 00234573201');
console.log(country); // 'AT'
console.log(account); // '1904300234573201'
console.log(checksum); // '61'
import { match } = from '@konfirm/iso13616';
console.log(match('AT 61 19043 00234573201'));
// { country: 'AT', checksum: '61', account: '1904300234573201' }
const { country, account, checksum } = match('AT 61 19043 00234573201');
console.log(country); // 'AT'
console.log(account); // '1904300234573201'
console.log(checksum); // '61'
As of version 3.0 the [Symbol.match]
is no longer supported, use ISO13616.match
instead.
MIT License Copyright (c) 2019-2021 Rogier Spieker (Konfirm)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.