isMongoId.js 599 B

12345678910111213141516171819202122
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isMongoId;
  6. var _assertString = require('./util/assertString');
  7. var _assertString2 = _interopRequireDefault(_assertString);
  8. var _isHexadecimal = require('./isHexadecimal');
  9. var _isHexadecimal2 = _interopRequireDefault(_isHexadecimal);
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function isMongoId(str) {
  12. (0, _assertString2.default)(str);
  13. return (0, _isHexadecimal2.default)(str) && str.length === 24;
  14. }
  15. module.exports = exports['default'];