The Relish constructor and .options helper accept an optional opts configuration object where:
opts- [object] optional configuration objectstripQuotes- [boolean] strip double quotes in default Joi messages (defaults tofalse)messages- [object] custom messages object- key - [string] either the full
pathor generickeyfrom the Joi schema (apathmatch takes priority) - value - [string] the custom message to be returned
- key - [string] either the full
Examples
const Relish = require('relish')({
stripQuotes: true, // affects default Joi messages only
messages: {
'email': 'A generic email key message',
'data.customer.email': 'A path-specific error message'
}
})
const failAction = Relish.failActionconst Relish = require('relish')({ stripQuotes: true })
const failAction = Relish.options({
messages: {
'email': 'A generic email key message',
'data.customer.email': 'A path-specific error message'
}
}).failActionA helper function that can be used as a custom failAction handler in your Hapi.js Route Options.