hapijs / hapijs/joi

Getting all possible validation errors for a given schema

Open
#2,937 3 comments 1 reaction 0 assignees View on GitHub
support
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*: 18
* *module version*: 17.6
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): standalone

#### How can we help?

Given some schema, how can I list all possible validation errors that can occur when validating an object against that schema.

For example for this schema:
```js
Joi.object({
foo: Joi.string().required().max(255),
bar: Joi.object({
baz: Joi.boolean(),
qux: Joi.number(),
}).required().xor('baz', 'qux')
})
```
I'd get:
```
. object.base
.foo any.required
.foo string.empty
.foo string.base
.foo string.max
.bar any.required
.bar object.xor(baz,qux)
.bar object.base
.bar.baz boolean.base
.bar.qux number.base
```

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.