import Joi from 'joi'; import globals from '../../globals'; export default class HelpValidate { private static help = { text: Joi.string() .allow('') .max(8192), level: Joi.string() .valid('none', ...Object.values(globals.levels)) } static input (data) { return Joi.object({ text: this.help.text.required(), level: this.help.level.required() }).validate(data); } static output (data) { const {value, error} = Joi.object({ text: this.help.text, level: this.help.level }).validate(data, {stripUnknown: true}); return error !== undefined? null : value; } static params(data) { return Joi.object({ key: Joi.string().min(1).max(128) }).validate(data); } }