-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect
Milestone
Description
Joi.array().includes validation error message doesnt give the proper path and error messages are not separated by fields.
test
var schema = Joi.object({
test: Joi.array().includes(Joi.object().keys({
foo: Joi.string().required().max(3),
bar: Joi.string().max(5)
}))
});
var value = {
test: [{
foo: 'test1',
bar: 'testfailed'
}]
};
Joi.validate(value, schema, {abortEarly: false}, function (err, value) {
console.log(err);
});result:
{ [ValidationError: test position 0 fails because foo length must be less than or equal to 3 characters long, bar length must be less than or equal to 5 characters long]
name: 'ValidationError',
details:
[ { message: 'test position 0 fails because foo length must be less than or equal to 3 characters long, bar length must be less than or equal to 5 characters long',
path: 'test.0.foo',
type: 'array.includesOne' } ],
_object: { test: [ [Object] ] },
annotate: [Function] }
Expecting two error messages. First path should show test.0.foo followed by test.0.bar.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect