Node.js 为mongoose验证设置错误代码
我正在使用mongoose验证来验证我的模型。例如:Node.js 为mongoose验证设置错误代码,node.js,mongodb,express,mongoose,Node.js,Mongodb,Express,Mongoose,我正在使用mongoose验证来验证我的模型。例如: var some_schema = new Schema({ title: { type : [String, 'title must be string'], required: [true, 'title is required'] } }) 此架构具有自定义错误消息,我也想设置自定义错误代码
var some_schema = new Schema({
title: {
type : [String, 'title must be string'],
required: [true, 'title is required']
}
})
此架构具有自定义错误消息,我也想设置自定义错误代码