isBIC.js 555 B

12345678910111213141516
  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. var countryCode = str.slice(4, 6).toUpperCase();
  8. if (!CountryCodes.has(countryCode) && countryCode !== 'XK') {
  9. return false;
  10. }
  11. return isBICReg.test(str);
  12. }