validateRef.js 383 B

12345678910111213141516171819
  1. 'use strict';
  2. const MongooseError = require('../../error/mongooseError');
  3. const util = require('util');
  4. module.exports = validateRef;
  5. function validateRef(ref, path) {
  6. if (typeof ref === 'string') {
  7. return;
  8. }
  9. if (typeof ref === 'function') {
  10. return;
  11. }
  12. throw new MongooseError('Invalid ref at path "' + path + '". Got ' +
  13. util.inspect(ref, { depth: 0 }));
  14. }