sepia-search-motore-di-rice.../server/middlewares/validators/pagination.ts

21 lines
599 B
TypeScript
Raw Normal View History

2020-02-13 11:49:03 +01:00
import * as express from 'express'
2020-05-29 09:13:22 +02:00
import { check } from 'express-validator'
2020-02-13 11:49:03 +01:00
import { areValidationErrors } from './utils'
const paginationValidator = [
2020-05-29 09:13:22 +02:00
check('start').optional().isInt({ min: 0 }).withMessage('Should have a number start'),
check('count').optional().isInt({ min: 0 }).withMessage('Should have a number count'),
2020-02-13 11:49:03 +01:00
(req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res)) return
return next()
}
]
// ---------------------------------------------------------------------------
export {
paginationValidator
}