implemented /help route
This commit is contained in:
34
src/routes/validate/help.ts
Normal file
34
src/routes/validate/help.ts
Normal file
@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user