预期的请求:
{
"name": "Raju",
"email": "email@email.com"
}
实际:
{
"name": "Raju",
"email": "email@email.com",
"xyz" : "xxxx"
}
我想在验证/路由器级别为“ xyz”抛出错误或转义。 我正在使用最快的验证程序。
还有其他验证器支持此功能吗?
任何帮助表示赞赏
答案 0 :(得分:0)
您可以像以下示例一样设置$$strict: true
:
const schema = {
name: { type: "string" }, // required
$$strict: true // no additional properties allowed
}
v.validate({ name: "John" }, schema); // Valid
v.validate({ name: "John", age: 42 }, schema); // Fail