Joi validation multiple conditions

I have the following schema:

var testSchema = Joi.object().keys({
    a: Joi.string(), 
    b: Joi.string(), 
    c: Joi.string().when('a', {'is': 'avalue', then: Joi.string().required()})
});

but I would like to add a condition on c field definition so that it is required when:

  • How to upload files using nodejs and HAPI?
  • Validation on relation between parameters, with hapijs/joi
  • React Router serverside rendering errors: Warning: Failed propType: Required prop `history` was not specified in `RoutingContext`
  • hapi.js best way to handle errors
  • Hapijs and Joi: validate query params with presence: 'forbidden'
  • Knowing request IP in Hapi.js Restful API
  • a == 'avalue' AND b=='bvalue'

    How can I do that?

  • How to log all requests made to a hapi server without using a logging library?
  • How to check if there is any payload (POST) data in a request with hapijs?
  • hapi set header before sending response
  • hapi.js best way to handle errors
  • how to make hapi good ignore a specific route
  • Why does my ES6 (using Babel) class say `this` is undefined in an instance method?
  • One Solution collect form web for “Joi validation multiple conditions”

    You can concatenate two when rules:

    var schema = {
        a: Joi.string(),
        b: Joi.string(),
        c: Joi.string().when('a', { is: 'avalue', then: Joi.string().required() }).concat(Joi.string().when('b', { is: 'bvalue', then: Joi.string().required() }))
    };