How can I create a validation rule using Joi that enforces the following condition: if valueA is empty, then valueB should have a value, and vice versa?
I'm currently using Joi to validate an array of objects that have valueA and valueB properties. Here's an example of the schema I'm using:
const schema = Joi.object({
valueA: Joi.string().pattern(/^\d+(,\d{1,2})?(\.\d{1,2})?$/)
valueB: Joi.string().pattern(/^\d+(,\d{1,2})?(\.\d{1,2})?$/)
});
I want to modify this schema to enforce the validation rule that either valueA or valueB has a value, and the other is empty. How can I do this using Joi?