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
path
or generickey
from the Joi schema (apath
match 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.failAction
const Relish = require('relish')({ stripQuotes: true })
const failAction = Relish.options({
messages: {
'email': 'A generic email key message',
'data.customer.email': 'A path-specific error message'
}
}).failAction
A helper function that can be used as a custom failAction handler in your Hapi.js Route Options.