<commit_before>Finnish IBAN and reference number validator/generator
=====================================================

[![Build Status](https://travis-ci.org/vkomulai/finnish-bank-utils.svg?branch=master)](https://travis-ci.org/vkomulai/finnish-bank-utils) ![0 deps](https://david-dm.org/vkomulai/finnish-bank-utils.svg)

- A micro Javascript library for validating and creating Finnish IBAN bank account numbers and reference numbers
- Lightweight, 3.8kB
- No dependencies
- Vanilla JS (ES6) + Babel for browser compatibility

Installation
------------

```sh
# NPM
npm install finnish-bank-utils

# Bower
bower install finnish-bank-utils
```

Usage
-----

Node.js

``` js
const FinnishBankUtils = require('finnish-bank-utils')
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
```

Browser: Writes FinnishBankUtils into global namespace.

``` html
<script src="finnish-bank-utils.min.js"></script>
<script>
  FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
</script>

```

Examples
--------

```sh
# Valid IBAN returns true, allows whitespace
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
FinnishBankUtils.isValidFinnishIBAN('FI 90 800026 2776 1348')
```

```sh
# Valid reference number returns true, allows whitespace
# !! Reference number type must be a string !!
FinnishBankUtils.isValidFinnishRefNumber('1511890656')
FinnishBankUtils.isValidFinnishRefNumber('15118 90656')
FinnishBankUtils.isValidFinnishRefNumber('RF34 1234 561')
```

```sh
# Generate a Finnish reference number
FinnishBankUtils.generateFinnishRefNumber()
// '6173672848'
```

```sh
# Generate a Finnish IBAN
FinnishBankUtils.generateFinnishRefIBAN()
// 'FI9080002627761348'
```

Functions
---------

##### isValidFinnishRefNumber(referenceNumber) : string --> boolean
-Validates parameter given reference number

##### isValidFinnishIBAN(ibanNumber) : string --> boolean
-Validates parameter given Finnish IBAN number

##### generateFinnishRefNumber() : void --> string
-Generates a random 10 char long Finnish reference number

##### generateFinnishIBAN() : void --> string
-Generates a random Finnish IBAN number

Building
--------

```sh
# Build a distributable, minified UMD library compatible with browsers and Node
npm run dist

# Run tests
npm run test
```

License
-------
[MIT License](LICENSE)<commit_msg>Add examples to readme<commit_after>Finnish IBAN and reference number validator/generator
=====================================================

[![Build Status](https://travis-ci.org/vkomulai/finnish-bank-utils.svg?branch=master)](https://travis-ci.org/vkomulai/finnish-bank-utils) ![0 deps](https://david-dm.org/vkomulai/finnish-bank-utils.svg)

- A micro Javascript library for validating and creating Finnish IBAN bank account numbers and reference numbers
- Lightweight, 3.8kB
- No dependencies
- Vanilla JS (ES6) + Babel for browser compatibility

Installation
------------

```sh
# NPM
npm install finnish-bank-utils

# Bower
bower install finnish-bank-utils
```

Usage
-----

Node.js

``` js
const FinnishBankUtils = require('finnish-bank-utils')
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
```

Browser: Writes FinnishBankUtils into global namespace.

``` html
<script src="finnish-bank-utils.min.js"></script>
<script>
  FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
</script>
```

Examples
--------

```sh
# Valid IBAN returns true, allows whitespace
FinnishBankUtils.isValidFinnishIBAN('FI9080002627761348')
FinnishBankUtils.isValidFinnishIBAN('FI 90 800026 2776 1348')
```

```sh
# Valid reference number returns true, allows whitespace
# !! Reference number type must be a string !!
FinnishBankUtils.isValidFinnishRefNumber('1511890656')
FinnishBankUtils.isValidFinnishRefNumber('15118 90656')
FinnishBankUtils.isValidFinnishRefNumber('RF34 1234 561')
```

```sh
# Valid IBAN returns formatted version, allows whitespace
FinnishBankUtils.formatFinnishIBAN('FI9080002627761348')
// 'FI90 8000 2627 7613 48'
```

```sh
# Valid reference number returns formatted version, allows whitespace
FinnishBankUtils.formatFinnishRefNumber('1511890656')
// '15118 90656'
FinnishBankUtils.formatFinnishRefNumber('RF341234561')
// 'RF34 1234 561'
```

```sh
# Generate a Finnish reference number
FinnishBankUtils.generateFinnishRefNumber()
// '6173672848'
```

```sh
# Generate a Finnish IBAN
FinnishBankUtils.generateFinnishRefIBAN()
// 'FI9080002627761348'
```

Functions
---------

##### isValidFinnishRefNumber(referenceNumber) : string --> boolean
- Validates parameter given reference number

##### isValidFinnishIBAN(ibanNumber) : string --> boolean
- Validates parameter given Finnish IBAN number

##### formatFinnishRefNumber(referenceNumber) : string --> string
- Formats parameter given reference number

##### formatFinnishIBAN(ibanNumber) : string --> string
- Formats parameter given Finnish IBAN number

##### generateFinnishRefNumber() : void --> string
- Generates a random 10 char long Finnish reference number

##### generateFinnishIBAN() : void --> string
- Generates a random Finnish IBAN number

Building
--------

```sh
# Build a distributable, minified UMD library compatible with browsers and Node
npm run dist

# Run tests
npm run test
```

License
-------
[MIT License](LICENSE)
{'fraction_non_alphanumeric': 0.14823977164605137, 'fraction_numerical': 0.060894386298763085, 'mean_word_length': 5.302158273381295, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5052700', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1632, 'n_words': 407}