import Boom from '@hapi/boom' ; import { AlertTypeParams , AlertTypeParamsValidator } from '../types' ; export function validateRuleTypeParams < Params extends AlertTypeParams > ( params , validator ? ) { if ( ! validator ) { return params as Params ; } try { return validator . validate ( params ) ; } catch ( err ) { throw Boom . badRequest ( `params invalid: ${ err . message }` ) ; } }