You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

4 years ago
  1. [![npm version](https://badge.fury.io/js/iban.svg)](https://badge.fury.io/js/iban)
  2. [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/arhs/iban.js/master/LICENSE)
  3. # iban.js
  4. IBAN and BBAN validation, formatting and conversion in Javascript.
  5. Check the demo on [demo page] to try it.
  6. [demo page]: https://arhs.github.io/iban.js/
  7. IBAN.js follows the [ISO 13616 IBAN Registry technical specification](https://www.swift.com/standards/data-standards/iban).
  8. ## Usage
  9. IBAN.js is compatible with both commonjs and AMD module definition. It can be used as a [node.js module](#in-nodejs) and [in the browser](#in-the-browser). It also has a bower manifest, a [Typescript definition](#with-typescript) and a [Meteor wrapper](#with-meteor-framework).
  10. ### In node.js
  11. ```js
  12. var IBAN = require('iban');
  13. IBAN.isValid('hello world'); // false
  14. IBAN.isValid('BE68539007547034'); // true
  15. ```
  16. ### In the browser
  17. Using a module loader (AMD or commonjs) or directly through the global ```IBAN``` object:
  18. ```html
  19. <script src="iban.js"></script>
  20. <script>
  21. // the API is now accessible from the window.IBAN global object
  22. IBAN.isValid('hello world'); // false
  23. IBAN.isValid('BE68539007547034'); // true
  24. </script>
  25. ```
  26. ### With TypeScript
  27. The library is also available from the typescript language. To do this, [download the definition](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/iban) and add a reference to this:
  28. ```typescript
  29. /// <reference path="iban.d.ts" />
  30. IBAN.isValid('hello world');
  31. IBAN.isValid('BE68539007547034');
  32. ```
  33. ### With Meteor framework
  34. A wrapper package for the Meteor framework is available [here](https://atmospherejs.com/theduke/iban).
  35. ## API
  36. * isValid(iban)
  37. * toBBAN(iban, separator)
  38. * fromBBAN(countryCode, bban)
  39. * isValidBBAN(countryCode, bban)
  40. * printFormat(iban, separator)
  41. * electronicFormat(iban)