-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: 8.9.0
- joi version: 10.6.0
- environment (node, browser): node
- used with (hapi, standalone, ...): hapi
What are you trying to achieve or the steps to reproduce ?
When trying to do the validation from a date dependant for another one and using joi.ref(...) an error related to a bad example occurs.
Here the code snippet to reproduce the problem:
server.route({
method: 'GET',
path: 'foo',
handler: (request, reply) => reply('OK'),
config: {
validate: {
query: joi.object({
fromDate: joi.date()
.iso()
.required()
.max(joi.ref('toDate'))
.example(new Date('2017-10-25T00:00:00.000Z')),
toDate: joi.date()
.iso()
.default(() => new Date(), 'Now')
.max('now')
.example(new Date('2017-10-28T00:00:00.000Z')),
}).unknown(),
},
},
});Which result you had ?
error: {
"message": "Bad example: \"value\" references \"toDate\" which is not a date",
"name": "Error",
...
}What did you expect ?
Return json data expected for this API.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect