What are you trying to achieve or the steps to reproduce?
I'm using Joi validation within a form, in which I'd like to not show the name of the field in the error messages as the errors will be displayed underneath the fields, so they don't need the additional context. I'm also using the same schema for validation within my Hapi backend, which I'd like to have the labels for.
The issue is that if you specify a label for a key, then the error messages don't respect the errors.label=false option, but keys without a label do respect it. If this is working as designed, then the docs should be adjusted for clarity:
false - remove any label prefix from error message, including the "".
Runtime
node.js, browser
Runtime version
v18.17.0, chrome 122
Module version
17.13.0
Last module version without issue
No response
Used with
Hapi, and standalone
Any other relevant information
No response
What are you trying to achieve or the steps to reproduce?
I'm using Joi validation within a form, in which I'd like to not show the name of the field in the error messages as the errors will be displayed underneath the fields, so they don't need the additional context. I'm also using the same schema for validation within my Hapi backend, which I'd like to have the labels for.
The issue is that if you specify a label for a key, then the error messages don't respect the
errors.label=false
option, but keys without a label do respect it. If this is working as designed, then the docs should be adjusted for clarity:Reduced example (from the schema tester):
Schema:
Data:
What was the result you got?
What result did you expect?