I am using joi in a node project, and I would like to put the following rule : my field could be of length 6 or 8 (nothing else), I've tried to do the following but its not working :
Joi.object({
iban: Joi.string().alphanum().length(6).length(8)
})
The last written rules override the first one, so here I only accept value with length 8 and no more value with length 6
Thanks in advance
Try writing custom validator like this. you can read more about custom validators here