- A micro Javascript library for validating, creating and formatting Finnish IBAN bank account numbers and reference numbers
- Lightweight, 5.2kB
- No dependencies
# NPM / yarn
npm install finnish-bank-utils
yarn install finnish-bank-utils
# Bower
bower install finnish-bank-utils
<!-- From unpkg.com -->
<script src="https://unpkg.com/finnish-bank-utils/finnish-bank-utils.min.js"></script>
Node.js
const FinnishBankUtils = require('finnish-bank-utils')
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
Browser: Writes FinnishBankUtils into global namespace.
<script src="finnish-bank-utils.min.js"></script>
<script>
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
</script>
# Valid IBAN returns true, allows whitespace
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
FinnishBankUtils.isValidFinnishIBAN('FI 90 800026 2776 1348')
# Valid reference number returns true, allows whitespace
# !! Reference number type must be a string !!
FinnishBankUtils.isValidFinnishRefNumber('1511890656')
FinnishBankUtils.isValidFinnishRefNumber('15118 90656')
# Allow international format for local reference number
FinnishBankUtils.isValidFinnishRefNumber('RF34 1234 561')
# Valid IBAN returns formatted version, allows whitespace
FinnishBankUtils.formatFinnishIBAN('FI9080002627761348')
// 'FI90 8000 2627 7613 48'
# Valid reference number returns formatted version, allows whitespace
FinnishBankUtils.formatFinnishRefNumber('1511890656')
// '15118 90656'
FinnishBankUtils.formatFinnishRefNumber('RF341234561')
// 'RF34 1234 561'
# Format Finnish virtual bar code (virtuaaliviidakoodi, pankkiviivakoodi)
# Supports versions 4 and 5
FinnishBankUtils.formatFinnishVirtualBarCode({iban: 'FI58 1017 1000 0001 22', sum: 482.99, reference: '55958 22432 94671', date: '31.1.2012'})
// '458101710000001220004829900000000559582243294671120131'
FinnishBankUtils.formatFinnishVirtualBarCode({iban: 'FI02 5000 4640 0013 02', sum: 693.8, reference: 'RF61 6987 5672 0839', date: '24.7.2011'})
// '502500046400013020006938061000000000698756720839110724'
# Parse Finnish virtual bar code (virtuaaliviidakoodi, pankkiviivakoodi)
# Supports versions 4 and 5
FinnishBankUtils.parseFinnishVirtualBarCode('458101710000001220004829900000000559582243294671120131')
// {iban: 'FI58 1017 1000 0001 22', sum: 482.99, reference: '55958 22432 94671', date: '31.1.2012'}
FinnishBankUtils.parseFinnishVirtualBarCode('502500046400013020006938061000000000698756720839110724')
// {iban: 'FI02 5000 4640 0013 02', sum: 693.8, reference: 'RF61 6987 5672 0839', date: '24.7.2011'}
# Generate a Finnish reference number
FinnishBankUtils.generateFinnishRefNumber()
// '6173672848'
FinnishBankUtils.generateFinnishRefNumber('617367284')
// '6173672848'
# Generate a Finnish IBAN
FinnishBankUtils.generateFinnishIBAN()
// 'FI9080002627761348'
- Validates parameter given reference number
- Validates parameter given Finnish IBAN number
- Formats parameter given reference number
- Formats parameter given Finnish IBAN number
formatFinnishVirtualBarCode({iban : string, sum : number, reference : string, date : string}) : object --> string
- Formats parameters to Finnish virtual bar code
- Parses parameter given Finnish virtual bar code
- Generates a (possibly random 10 char long) Finnish reference number.
- Generates a random Finnish IBAN number
# Build a distributable, minified UMD library compatible with browsers and Node
npm run dist
# Run tests
npm run test