hapijs / hapijs/joi

Passing meta data from schema to validation result

Open
#2,939 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:
* *is this issue affecting a production system?* no:

#### Context

* *node version*: v16.14.0
* *module version*: 17.6.0
* *environment* browser
* *used with* (e.g. hapi application, another framework, standalone, ...):
* *any other relevant information*:

#### How can we help?

Hi team,
I would like to tag a schema with some metadata that will be included in any validation result of that schema or its children schema.
Is this possible with the current state of Joi?

I think it is similar to `artifact` but also work for failed rule.

```js
const schema = Joi.object({
name: Joi.string().required(),
})
.schemaTag('special-tag')

const result = schema.validate(
{ gaga: 'gaga' }
)

console.log(result.details.map(detail => detail.schemaTag))) // ['special-tag']
```

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.