Imagine than we have a,b,c fields.
a: Joi.string().required(),
b: Joi.any()
.when('a', {is: 'Other', then: Joi.any(), otherwise: Joi.string().required()}),
c: Joi.alternatives()
.when('a', {is: 'Other', then: Joi.string().required()})
.when('b', {is: 'Other', then: Joi.string().required()})
a - is always required.
b - required only if a != 'Other'
c - required only if a == 'Other' OR b == 'Other'
If none of c rules has been applied c should be optional()
How should I rebuild my schema to get last rule working?
Imagine than we have a,b,c fields.
a- is always required.b- required only ifa!= 'Other'c- required only ifa== 'Other' ORb== 'Other'If none of
crules has been appliedcshould be optional()How should I rebuild my schema to get last rule working?