is-valid.js 348 B

123456789101112131415
  1. 'use strict';
  2. var alphabet = require('./alphabet');
  3. function isShortId(id) {
  4. if (!id || typeof id !== 'string' || id.length < 6 ) {
  5. return false;
  6. }
  7. var nonAlphabetic = new RegExp('[^' +
  8. alphabet.get().replace(/[|\\{}()[\]^$+*?.-]/g, '\\$&') +
  9. ']');
  10. return !nonAlphabetic.test(id);
  11. }
  12. module.exports = isShortId;