gpt4 book ai didi

javascript - 在所有 Sequelize 验证中获得非错误警告?

转载 作者:行者123 更新时间:2023-11-29 21:38:30 25 4
gpt4 key购买 nike

当我的任何 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 库,最后显示警告:

https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md#warning-a-promise-was-rejected-with-a-non-error

您可以忽略该警告。

关于javascript - 在所有 Sequelize 验证中获得非错误警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34091538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com