-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
featureNew functionality or improvementNew functionality or improvement
Milestone
Description
Context
- node version: 6.9.1
- joi version: 9.2.0
- environment: node
- used with: expressjs
What are you trying to achieve or the steps to reproduce ?
Describe your issue here, include schemas and inputs you are validating if needed.
const schema = Joi.object().keys({
numberOfAdults: Joi.number().integer().min(1).max(10).required(),
numberOfChildren: Joi.number().integer().min(1).max(10),
childAges: Joi.when('numberOfChildren', {
is: Joi.number().required(),
then: Joi.array().items(Joi.number().integer().required()).length(Joi.ref('numberOfChildren')).required()
})
})Which result you had ?
Error: limit must be a positive integer
<br> at Object.exports.assert (/Users/buianhthang/my_project/node_modules/joi/node_modules/hoek/lib/index.js:736:11)
<br> at length (/Users/buianhthang/my_project/node_modules/joi/lib/array.js:421:14)
What did you expect ?
expect childAges length equals numberOfChildren value
{
"code": 400,
"message": "Missing or invalid params",
"verbosity": [
{
"message": "\"childAges\" must contain (x) items",
"path": "roomList.0.childAges",
"type": "array.length",
"context": {
"limit": 5,
"value": [
4
],
"key": "childAges"
}
}
]
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionality or improvementNew functionality or improvement