hapijs / hapijs/joi

Validate the validation: Disallow certain feature/combinations

Open
#2,893 0 comments 0 reactions 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*: 14.21.1
* *module version*: 17.6.1
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): express
* *any other relevant information*:

#### How can we help?

I'm setting up a new project which is expected to get quite large. Having very strict validation from the very beginning is crucial. However, in large projects with many people working on them, things tend to get out of hand and eventually less strict validation sneaks in. Once that's the case, it's hard to make the validation strict again (I've been there). So, I was just wondering: Is there a way to automatically enforce strict validation by reducing the options/possibilities of Joi?

I was thinking of **disallowing**:
- The usage of `Joi.any()`
- The usage of `Joi.object` without further narrowing down (by `.keys`, `.pattern` etc.)
- The usage of `Joi.array` withouth `items` etc.
- The usage of `Joi.string()` without narrowing down (`.email()` , regex etc)

Is that possible somehow?

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.