2
我对使用Joi验证hapi中的请求有效载荷相当陌生。我的问题如下。我有这个定义的路线:在Joi中允许可选参数,而不指定它们
{
method: 'POST',
path: '/foo/bar',
config: {
description: 'foo.bar',
handler: handlers.foo,
auth:false,
tags: ['api'],
validate: {
payload: {
email : Joi.string().required(),
password : Joi.string().required(),
}
}
}
}
电子邮件和密码是我的必需属性。但是,我想允许其他属性,而不必全部指定它们。例如:
{
email: [email protected],
password: fooPass,
name: myName,
surname: mySurname
}
有没有办法与Joi做到这一点?