X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fpagination.ts;h=1cae7848c400fe14f40392f5152c7e96a2097933;hb=4ddcb7c3bad4e98d05d25298f7f11353a639b360;hp=e1ed8cd65cb6979c7c85fdb1aee46f1b6cceec01;hpb=da854ddd502cd70685ef779c673b9e63757b8aa0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts index e1ed8cd65..1cae7848c 100644 --- a/server/middlewares/validators/pagination.ts +++ b/server/middlewares/validators/pagination.ts @@ -1,11 +1,16 @@ import * as express from 'express' -import { query } from 'express-validator/check' +import { query } from 'express-validator' import { logger } from '../../helpers/logger' import { areValidationErrors } from './utils' +import { PAGINATION } from '@server/initializers/constants' const paginationValidator = [ - query('start').optional().isInt({ min: 0 }).withMessage('Should have a number start'), - query('count').optional().isInt({ min: 0 }).withMessage('Should have a number count'), + query('start') + .optional() + .isInt({ min: 0 }).withMessage('Should have a number start'), + query('count') + .optional() + .isInt({ min: 0, max: PAGINATION.GLOBAL.COUNT.MAX }).withMessage(`Should have a number count (max: ${PAGINATION.GLOBAL.COUNT.MAX})`), (req: express.Request, res: express.Response, next: express.NextFunction) => { logger.debug('Checking pagination parameters', { parameters: req.query })