How to validate all items in array have the same type
Open
feature
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
* *node version*: 12.14.1
* *module version*: 11.4.0
* *environment* node
* *used with* hapi application
My array can have multiple types:
`[Joi.string(), Joi.number(), Joi.boolean(), Joi.array(), Joi.object()]`
But I want to allow only one of them in the same time.
I tried the following:
`attributes: Joi.object().pattern(/\w+/, Joi.alternatives().try([Joi.array().items(Joi.string()), Joi.array().items(Joi.number()), Joi.array().items(Joi.boolean()), Joi.array().items(Joi.array()), Joi.array().items(Joi.object())]))`
Is there any way to perform such a validation? Does it work in another vesrion?
Contributor guide
Assessment
This issue has not been assessed yet.