-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
featureNew functionality or improvementNew functionality or improvement
Milestone
Description
I discovered a possible bug in how array().include() validates nested objects (see below for each of the two use cases). Also, the fail message is cryptic.
Thus far, I've only tried this with array() and no other types.
I'd like test to be required. It should be of type array that is an array of objects that have a required field foo.
var Joi = require('joi');
var schema = {
test: Joi.array().includes(Joi.object({
foo: Joi.string().required()
})).required()
}
/* passes
This passes but should fail because foo is required.
*/
console.log( Joi.validate({ test: [] }, schema) );
/* fails with bad error message
{ _errors:
[ { message: 'the value [object Object] in test does not match any of the allowed types',
path: 'test' } ],
_object: { test: [ [Object] ] },
message: 'the value [object Object] in test does not match any of the allowed types' }
*/
console.log( Joi.validate({ test: [{'test': 'test'}] }, schema) );Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionality or improvementNew functionality or improvement