hapijs / hapijs/joi

Multiple condition

Open
#2,683 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
21.2k
Forks
1.5k
Avg merge
4h 57m
Merged PRs (30d)
14

Description

#### Support plan

* *is this issue currently blocking your project?* (yes/no): no
* *is this issue affecting a production system?* (yes/no): no

#### Context

* *node version*: v14.17.6
* *module version*: 17.4.2
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone
* *any other relevant information*:

#### How can we help?

```js
const schema = {
a: Joi.any(),
b: Joi
.boolean()
.default(false),
c: Joi
.boolean()
.default(false)
}
```

How can I fix the abovementioned Joi schema to matches the following rules, I tried nested `when` but not works

- One of `b` or `c` can be `true` at the same time
- When `b` or `c` is `true`, `a` is `forbidden` otherwise `a` is `required`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.