X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fpagination.ts;h=1cae7848c400fe14f40392f5152c7e96a2097933;hb=4ddcb7c3bad4e98d05d25298f7f11353a639b360;hp=80ae57c0bba7d790130cf7f31d406be29a2c92e1;hpb=c8861d5dc0436ef4342ce517241e3591fa256a13;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/pagination.ts b/server/middlewares/validators/pagination.ts index 80ae57c0b..1cae7848c 100644 --- a/server/middlewares/validators/pagination.ts +++ b/server/middlewares/validators/pagination.ts @@ -2,10 +2,15 @@ import * as express from 'express' 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 })