refactor: validators

This commit is contained in:
wancat committed 2024-02-19 19:09:32 +08:00
1 parent 5e8df7ae01
commit ad66191d88
4 files changed

No files matched your search

@@ -0,0 +1,17 @@
import { body } from 'express-validator'
import { noError } from '../../middleware/validator.js'
const checkCommand = () => body('command').isString().notEmpty().trim()
const checkPwd = () => body('pwd').isString().notEmpty().trim()
const checkOutput = () => body('output').trim().optional()
const checkError = () => body('error').trim().optional()
const checkParams = () => body('params').isObject().optional()
export const newCommandValidator = [
checkCommand(),
checkPwd(),
checkOutput(),
checkError(),
checkParams(),
noError,
]