isBIC.js 826 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isBIC;
  6. var _assertString = _interopRequireDefault(require("./util/assertString"));
  7. var _isISO31661Alpha = require("./isISO31661Alpha2");
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. // https://en.wikipedia.org/wiki/ISO_9362
  10. var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
  11. function isBIC(str) {
  12. (0, _assertString.default)(str); // toUpperCase() should be removed when a new major version goes out that changes
  13. // the regex to [A-Z] (per the spec).
  14. if (!_isISO31661Alpha.CountryCodes.has(str.slice(4, 6).toUpperCase())) {
  15. return false;
  16. }
  17. return isBICReg.test(str);
  18. }
  19. module.exports = exports.default;
  20. module.exports.default = exports.default;