Open
Description
Runtime
n/a
Runtime version
n/a
Module version
n/a
Used with
No response
Any other relevant information
No response
How can we help?
const myCustomFn = (value, helpers) => {
// If condition is matched I want to set both code 'my.error.code' and message inside this myCustomFn
// but helpers.error() does not allow setting message and helpers.message() does not allow setting code other then "custom"
// and I do not want in many places in code use .custom() with combination .messages() because messages will be repetitive:
// .custom(myCustomFn).messages({ 'my.error.code' : 'My error message' })
// I tried to use helpers.prefs.messages['my.error.code'] = 'My error message' but it causes error
if (.........)
return helpers.error('my.error.code');
return value;
};
joi.object({
.........
})
.xor(.......)
.custom(myCustomFn)