Context
- node version: v4.4.3
- joi version: ^9.0.0-0
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
- any other relevant information:
What are you trying to achieve or the steps to reproduce ?
Describe your issue here, include schemas and inputs you are validating if needed.
When using reach, the new label is ignored.
const Joi = require('joi');
const schema = Joi.object({ foo: Joi.number().label('foo_1') });
const reachSchema = Joi.object({
a: Joi.reach(schema, 'foo').label('foo_2')
});
console.log(reachSchema.validate({ a: 'blah' }).error);
Which result you had ?
Error: child "a" fails because ["foo_1" must be a number]
message: "\"foo_1\" must be a number"
path: "a"
type: "number.base"
name: "ValidationError"
What did you expect ?
message: "\"foo_2\" must be a number"