Improve error message
"use strict"
const Joi = require('joi')
const moves = {
like: 'jagger',
true: 'maybe'
}
const def = Joi.object({
true: Joi.string().valid('maybe')
})
// OK
console.log(String(def.validate(moves).error))
// ValidationError: "like" is not allowed
// NOT OK
console.log(String(def.label('Moves').validate(moves).error))
// ValidationError: "Moves" is not allowed
// EXPECTED
// ValidationError: "like" is not allowed for "Moves"
// OR AT LEAST
// ValidationError: "like" is not allowed
Root can't really have a label since it doesn't have a name in javascript, there's no path to access it.
Don't really understand what you are referring to as root and the fact that it doesn't have label?
The above code works, and the validation is wotking also, but the error generated now is missleading if the object has a label.
Can you confirm the issue?
I see, misinterpreted your report, it's already been fixed in 7.2.2, which version are you running ?
Unfortunately I'm using 7.2.2 and seeing this
Confirmed, I'll fix it in a while, just noticed 7.2.2 actually introduced a bug.
thanks !