当触发任何 Sequelize 验证时,我会在控制台中收到非错误
警告。以下是一个字段验证的示例:
company_name: {
type: Sequelize.STRING(100),
allowNull: true,
validate: {
not: {args: [badWordsList.regex], msg: "Try to keep the profanity to a minimum."},
len: {args: [0, 100], msg: "Your company name cannot be greater than 100 characters long."}
}
}
警告是堆栈跟踪,如下所示:
Warning: a promise was rejected with a non-error: [object String]
at /Users/<user>/Documents/Webstorm Projects/<project>/node_modules/sequelize/lib/instance-validator.js:193:33
at /Users/<user>/Documents/Webstorm Projects/<project>/node_modules/lodash/index.js:3073:15
...
我尝试过更新和升级 npm,但没有成功解决这些警告。否则一切正常。有什么办法可以防止或抑制这些警告吗?如果需要的话,我将包含更多的堆栈跟踪。谢谢!
最佳答案
如果你检查instance-validator.js
的代码,它似乎会抛出msg
作为错误:
https://github.com/sequelize/sequelize/blob/master/lib/instance-validator.js#L275
sequelize
使用 Bluebird
Promise 库,它在末尾显示警告:
您可以忽略该警告。
关于javascript - 所有 Sequelize 验证都收到非错误警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34091538/