isBIC.js 497 B

1234567891011121314
  1. import assertString from './util/assertString';
  2. import { CountryCodes } from './isISO31661Alpha2'; // https://en.wikipedia.org/wiki/ISO_9362
  3. var isBICReg = /^[A-Za-z]{6}[A-Za-z0-9]{2}([A-Za-z0-9]{3})?$/;
  4. export default function isBIC(str) {
  5. assertString(str); // toUpperCase() should be removed when a new major version goes out that changes
  6. // the regex to [A-Z] (per the spec).
  7. if (!CountryCodes.has(str.slice(4, 6).toUpperCase())) {
  8. return false;
  9. }
  10. return isBICReg.test(str);
  11. }