Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以验证布尔值是否正在true使用 Joi?我试过使用allow,valid但invalid没有任何运气。
true
allow
valid
invalid
你有没有尝试过这样的事情:
var schema = Joi.boolean().invalid(false);
使用该模式,以下所有内容都会填充错误属性:
Joi.validate(false, schema); Joi.validate('false', schema); Joi.validate('no', schema); Joi.validate('off', schema); Joi.validate(0, schema);