We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
node.js
20
17.13
standalone
No response
I would like to add custom properties to the context object of the returned error.
context
Given the following schema:
const projectSchema = object.keys({ id: number.required(), description: string.required(), records: array.items(object.keys({ id: number.required(), title: string.required(), })).min(2).required() })
I would like to automatically annotate the returned errors with their respective parents' ID. e.g.
[ { message: '"description" is not allowed to be empty', path: [ 'description' ], type: 'description.empty', context: { **projectId: 12** label: 'title', value: '', key: 'title' }, { message: '"title" is not allowed to be empty', path: ['records', '0', 'title' ], type: 'string.empty', context: { **recordId: 21** **projectId: 12** label: 'title', value: '', key: 'title' } ]
I've tried something like this already but doesn't seem to be working:
title: string .error((err) => { err.forEach((err) => { err.local.msg = Joi.ref('id') }) return err }) .required(),
Thank you!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Runtime
node.js
Runtime version
20
Module version
17.13
Used with
standalone
Any other relevant information
No response
How can we help?
I would like to add custom properties to the
context
object of the returned error.Given the following schema:
I would like to automatically annotate the returned errors with their respective parents' ID. e.g.
I've tried something like this already but doesn't seem to be working:
Thank you!
The text was updated successfully, but these errors were encountered: