isBIC.js 555 B

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