0
 body: Joi.object({
            "a": Joi.boolean().default(true),
            "b": Joi.boolean().default(true),
            "c": Joi.string().default("abc"),
            "d": Joi.string().default("abc"), 
        })

I have to ensure that either a or b is true. How can I do that?

RemyaJ
  • 5,358
  • 4
  • 22
  • 41
  • 1
    You might try adding something like this to your schema `.when('b', { is: false, then: Joi.valid(true), otherwise: Joi.valid(true, false) })`. The only problem is that I'm not sure how to get around the circular dependency when you add the inverse of that for `'a'` on the `'b'` schema. See more [here](https://stackoverflow.com/a/26511692/1913185) & [here](https://stackoverflow.com/a/55137182/1913185). Link to Joi's [when](https://hapi.dev/family/joi/?v=16.1.7#anywhencondition-options). – technogeek1995 Nov 20 '19 at 21:50
  • 1
    Yeah it creates a circular dependency when I do that. – RemyaJ Nov 21 '19 at 04:18

0 Answers0