Custom error is ignored with multiply array items
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
#### Support plan
* *is this issue currently blocking your project?* (yes/no): yes
* *is this issue affecting a production system?* (yes/no): no
#### Context
* *node version*: 14.19.0
* *module version with issue*: 17.9.1, 17.9.2
* *last module version without issue*:
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...):
* *any other relevant information*:
#### What are you trying to achieve or the steps to reproduce?
Schema:
```js
Joi.object({
test: Joi.array().items(
Joi.string(),
Joi.number()
.custom(function(value, helpers){
if (value===5)
return helpers.error('test_error');
return value;
})
.messages({
'test_error': 'Test error message',
})
).single(),
})
```
Data To Validate:
```js
{
test: 5,
}
```
#### What was the result you got?
`Validation Error: "test" does not match any of the allowed types`
#### What result did you expect?
`Validation Error: Test error message`
Contributor guide
Assessment
This issue has not been assessed yet.