-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
featureNew functionality or improvementNew functionality or improvement
Milestone
Description
Hello, I stumbled accross the following behavior using the joi version provided by npm:
When I set abortEarly: false, no unique error is returned if there is a previous error, e.g. from required.
Example:
console.log(Joi.validate([
{
test: 'test',
hello: 'world',
},
{
test: 'test',
}
], Joi.array().items(Joi.object().keys({
test: Joi.string(),
hello: Joi.string(),
})).unique('test'), {abortEarly: false}).error.details);This outputs the following as expected:
[ { message: '"value" position 1 contains a duplicate value',
path: [ 1 ],
type: 'array.unique',
context:
{ pos: 1,
value: [Object],
dupePos: 0,
dupeValue: [Object],
path: 'test',
key: 1,
label: 'value' } } ]
However:
console.log(Joi.validate([
{
test: 'test',
hello: 'world',
},
{
test: 'test',
}
], Joi.array().items(Joi.object().keys({
test: Joi.string(),
hello: Joi.string().required(),
})).unique('test'), {abortEarly: false}).error.details);only outputs the following
[ { message: '"hello" is required',
path: [ 1, 'hello' ],
type: 'any.required',
context: { key: 'hello', label: 'hello' } } ]
I'd expect the two errors to be returned in the second example. I'm not sure if this is a bug.
Thanks in advance for your efforts!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionality or improvementNew functionality or improvement