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
Here's an example of a test Joi extension that always produces an error.
let Joi = require('joi@9.0.0-5'); Joi = Joi.extend({ base: Joi.any(), name: 'any', language: { anytest: 'is a test' }, rules: [{ name: 'anytest', validate(params, value, state, options) { return this.createError('any.anytest', { v: value }, state, options); // always creates an error } }] }); Joi.any().anytest().label('myString').validate('foo');
The above produces an error object with: Error: "value" is a test
Error: "value" is a test
I expected the label to be included in the error message: Error: "myString" is a test
Error: "myString" is a test
This native Joi example produces what I would expect:
Joi.string().label('myString').validate(1)
✅ Produces Error: "myString" must be a string
Error: "myString" must be a string
The text was updated successfully, but these errors were encountered:
Good spotting @MarkHerhold, fixing now.
Sorry, something went wrong.
55dc1e1
Released as 9.0.0-6.
Thanks @Marsup!
Marsup
No branches or pull requests
Context
What are you trying to achieve or the steps to reproduce ?
Here's an example of a test Joi extension that always produces an error.
Which result you had ?
The above produces an error object with:
Error: "value" is a test
What did you expect ?
I expected the label to be included in the error message:
Error: "myString" is a test
Native Joi example of what I expected:
This native Joi example produces what I would expect:
✅ Produces
Error: "myString" must be a string
The text was updated successfully, but these errors were encountered: