mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 11:53:49 +00:00
refactor: simplify validations
This commit is contained in:
@@ -2,7 +2,7 @@ import { body, param, validationResult } from 'express-validator';
|
||||
import type { Request, Response, NextFunction } from 'express';
|
||||
|
||||
export const rundownPostValidator = [
|
||||
body('type').isString().exists().isIn(['event', 'delay', 'block']),
|
||||
body('type').isString().isIn(['event', 'delay', 'block']),
|
||||
body('after').optional().isString(),
|
||||
body('before').optional().isString(),
|
||||
|
||||
@@ -14,7 +14,7 @@ export const rundownPostValidator = [
|
||||
];
|
||||
|
||||
export const rundownPutValidator = [
|
||||
body('id').isString().exists(),
|
||||
body('id').isString().notEmpty(),
|
||||
|
||||
(req: Request, res: Response, next: NextFunction) => {
|
||||
const errors = validationResult(req);
|
||||
@@ -24,7 +24,7 @@ export const rundownPutValidator = [
|
||||
];
|
||||
|
||||
export const rundownBatchPutValidator = [
|
||||
body('data').isObject().exists(),
|
||||
body('data').isObject(),
|
||||
body('ids').isArray().notEmpty(),
|
||||
body('ids.*').isString(),
|
||||
|
||||
@@ -36,9 +36,9 @@ export const rundownBatchPutValidator = [
|
||||
];
|
||||
|
||||
export const rundownReorderValidator = [
|
||||
body('entryId').isString().exists(),
|
||||
body('destinationId').isString().exists(),
|
||||
body('order').isIn(['before', 'after', 'insert']).exists(),
|
||||
body('entryId').isString().notEmpty(),
|
||||
body('destinationId').isString().notEmpty(),
|
||||
body('order').isIn(['before', 'after', 'insert']),
|
||||
|
||||
(req: Request, res: Response, next: NextFunction) => {
|
||||
const errors = validationResult(req);
|
||||
@@ -48,8 +48,8 @@ export const rundownReorderValidator = [
|
||||
];
|
||||
|
||||
export const rundownSwapValidator = [
|
||||
body('from').isString().exists(),
|
||||
body('to').isString().exists(),
|
||||
body('from').isString().notEmpty(),
|
||||
body('to').isString().notEmpty(),
|
||||
|
||||
(req: Request, res: Response, next: NextFunction) => {
|
||||
const errors = validationResult(req);
|
||||
@@ -59,7 +59,7 @@ export const rundownSwapValidator = [
|
||||
];
|
||||
|
||||
export const paramsMustHaveEntryId = [
|
||||
param('entryId').exists(),
|
||||
param('entryId').isString().notEmpty(),
|
||||
|
||||
(req: Request, res: Response, next: NextFunction) => {
|
||||
const errors = validationResult(req);
|
||||
|
||||
Reference in New Issue
Block a user