Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Latest commit

 

History

History
52 lines (41 loc) · 1.5 KB

API.md

File metadata and controls

52 lines (41 loc) · 1.5 KB

API Documentation - v3.0.0

Relish

constructor / options([opts])

The Relish constructor and .options helper accept an optional opts configuration object where:

  • opts - [object] optional configuration object
    • stripQuotes - [boolean] strip double quotes in default Joi messages (defaults to false)
    • messages - [object] custom messages object
      • key - [string] either the full path or generic key from the Joi schema (a path match takes priority)
      • value - [string] the custom message to be returned

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

failAction(request, h, err)

A helper function that can be used as a custom failAction handler in your Hapi.js Route Options.