[feature] provide method by which to attach additional metadata to the returned ValidationError
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
#### Context
```
❯ npm explain joi && node --version && uname -a
joi@17.6.0
v16.14.2
Darwin 5c52309d33e3 20.6.0 Darwin Kernel Version 20.6.0: Tue Apr 19 21:04:45 PDT 2022; root:xnu-7195.141.29~1/RELEASE_X86_64 x86_64 i386 Darwin
```
#### What problem are you trying to solve?
I need some kind of parent label that can be retrieved from the Validation Error Message. We have essentially `User.firstName` throwing an undefined (because required) error. Unfortunately `ValidationError` only provides `firstName` in the metadata, and there is no way for me to see that the root object has label `User`.
I need some way to supply to the error handler via the ValidationError the meta data `User`. I've tried `label`, `meta`, `notes`, `error()` etc. None of it carries the data, and most of it doesn't even show up in the validation error (why does it exist?).
#### Do you have a new or modified API suggestion to solve the problem?
just put things like meta and parent label, etc in the validation error details.
Contributor guide
Assessment
This issue has not been assessed yet.