hapijs / hapijs/joi

Validation - only allow SINGLE LAYER of nesting for a property whose value is an object

Open
#2,662 0 comments 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*: 14
* *module version*: 17
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): expressjs
* *any other relevant information*: nil

#### What problem are you trying to solve?
Is there a way to only allow a SINGLE layer for a property which is an object? meaning no nesting... lets take the following example:

```javascript
{
"hello": {
"foo": 1,
"bar": 2
},
"world": 3
}
```

the property `hello` is an object of `{"foo": 1, "bar": 2}`.

This should pass validation.

If we were to add an object that is further nested, then it will fail, for example:
```javascript
{
"hello": {
"foo": 1,
"bar": {
"good": 4,
"bye": 5
}
},
"world": 3
}
```
In essense, how do I ensure only a single layer and no nesting for a selected property, which has an object as a value?

#### Do you have a new or modified API suggestion to solve the problem?
No

Contributor guide

Open the contributing guide

Research direction

The issue names no source file, test, or entry point. Start by checking Joi's existing object-validation API against the two example objects; done would mean a schema accepts the one-level object and rejects the nested object.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.