-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
bugBug or defectBug or defect
Description
Hi, not sure if this is a problem of Joi itself or the integration with Hapi.
I'm doing the following validation in a route:
server.route({
method: 'POST',
path: '/register',
config: {
validate: {
payload: Joi.object({
username: Joi.string().regex(/^[a-z0-9_\.]+$/i).required(),
email: Joi.string().email().required(),
password: Joi.string().min(6).required(),
confirm: Joi.object().keys({
email: Joi.string().required(),
password: Joi.string().required()
}).required()
}).assert('confirm.email', Joi.ref('email'))
.assert('confirm.password', Joi.ref('password'))
.required()
, options: {abortEarly: false}
},
handler: function() {}
});The problem is with the assert validation. If I send different emails and passwords I get the following response:
{ statusCode: 400,
error: 'Bad Request',
message: 'value validation failed because confirm.email failed to pass the assertion test. value validation failed because confirm.password failed to pass the assertion test',
validation: { source: 'payload', keys: [ 'value', 'value' ] } }Shouldn't the keys be 'confirm.email' and 'confirm.password' instead of 'value'? Am I doing something wrong?
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect