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.
我正在尝试验证查询字符串中相互依赖的可选参数。换句话说,当添加参数A时,还需要参数B。这两个参数都是可选的,所以当它们都没有提供时,验证也应该通过。
应该通过:
?a=1&b=2&c=0 ?c=0
应该失败:
?a=1&c=0 ?b=2&c=0
有人可以给我一个关于如何解决这个问题的示例模式吗?
看看Joi.object().and()
Joi.object().keys({ a: Joi.number(), b: Joi.number(), c: Joi.number() }).and('a', 'b');