Javascript regExp mongoose-对象#<;对象>;没有方法';测试';

Javascript regExp mongoose-对象#<;对象>;没有方法';测试';,javascript,node.js,mongodb,mongoose,sails.js,Javascript,Node.js,Mongodb,Mongoose,Sails.js,我正在尝试运行mongoose document.save,但出现以下错误: TypeError: Object #<Object> has no method 'test' at model.matchValidator (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\schema\string.js:221:16) at SchemaType.doValidate (C:\wamp\www\Ayo

我正在尝试运行mongoose document.save,但出现以下错误:

TypeError: Object #<Object> has no method 'test'
    at model.matchValidator (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\schema\string.js:221:16)
    at SchemaType.doValidate (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\schematype.js:627:28)
    at Array.forEach (native)
    at SchemaString.SchemaType.doValidate (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\schematype.js:614:19)
    at Document.validate.err (C:\wamp\www\Ayolan-Translation\node_modules\mongoose\lib\document.js:956:9)
    at process._tickCallback (node.js:415:13)
当我查看regExp时,它是一个只有proto的对象,仅此而已。
我不知道问题出在哪里,当我正常运行我的应用程序时,它工作正常,知道吗?

但是,这段代码来自mongoose,我无法修改它。我的意思是,它应该自己工作!我还试图手动导入我的模式并创建模型,但出现了相同的错误。您能否编辑您的问题,以包括模式定义和调用
save
的代码?恐怕这个问题是一年前提出的,而且代码已经不存在了。我要关闭它。好吧,也许最好还是删除它。
SchemaString.prototype.match = function match (regExp, message) {
  // yes, we allow multiple match validators

  var msg = message || errorMessages.String.match;

  function matchValidator (v){
    return null != v && '' !== v
      ? regExp.test(v)
      : true
  }

  this.validators.push([matchValidator, msg, 'regexp']);
  return this;
};