-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Context
- node version: 6.2.1
- joi version: 9.0.0-5
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
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.
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');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:
Joi.string().label('myString').validate(1)✅ Produces Error: "myString" must be a string
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defect