diff options
Diffstat (limited to 'server/middlewares/validators/pagination.js')
-rw-r--r-- | server/middlewares/validators/pagination.js | 21 |
1 files changed, 21 insertions, 0 deletions
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 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const checkErrors = require('./utils').checkErrors | ||
4 | const logger = require('../../helpers/logger') | ||
5 | |||
6 | const validatorsPagination = { | ||
7 | pagination: pagination | ||
8 | } | ||
9 | |||
10 | function pagination (req, res, next) { | ||
11 | req.checkQuery('start', 'Should have a number start').optional().isInt() | ||
12 | req.checkQuery('count', 'Should have a number count').optional().isInt() | ||
13 | |||
14 | logger.debug('Checking pagination parameters', { parameters: req.query }) | ||
15 | |||
16 | checkErrors(req, res, next) | ||
17 | } | ||
18 | |||
19 | // --------------------------------------------------------------------------- | ||
20 | |||
21 | module.exports = validatorsPagination | ||