From fc51fde048f2c3ce1dd3e85f5528335040bae894 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 1 Jul 2016 16:16:40 +0200 Subject: reqValidators --> validators --- server/middlewares/validators/pagination.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 server/middlewares/validators/pagination.js (limited to 'server/middlewares/validators/pagination.js') diff --git a/server/middlewares/validators/pagination.js b/server/middlewares/validators/pagination.js new file mode 100644 index 000000000..8e9a01053 --- /dev/null +++ b/server/middlewares/validators/pagination.js @@ -0,0 +1,21 @@ +'use strict' + +const checkErrors = require('./utils').checkErrors +const logger = require('../../helpers/logger') + +const validatorsPagination = { + pagination: pagination +} + +function pagination (req, res, next) { + req.checkQuery('start', 'Should have a number start').optional().isInt() + req.checkQuery('count', 'Should have a number count').optional().isInt() + + logger.debug('Checking pagination parameters', { parameters: req.query }) + + checkErrors(req, res, next) +} + +// --------------------------------------------------------------------------- + +module.exports = validatorsPagination -- cgit v1.2.3