在所有 Sequelize 验证中获得非错误警告?
Getting a non-error warning on all Sequelize validations?
当我的任何 Sequelize 验证被触发时,我在控制台中收到 non-error
警告。这是一个字段验证的示例:
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 库,最后显示警告:
您可以忽略该警告。
当我的任何 Sequelize 验证被触发时,我在控制台中收到 non-error
警告。这是一个字段验证的示例:
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 库,最后显示警告:
您可以忽略该警告。