aboutsummaryrefslogtreecommitdiffhomepage
path: root/middlewares/reqValidators/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'middlewares/reqValidators/utils.js')
-rw-r--r--middlewares/reqValidators/utils.js36
1 files changed, 17 insertions, 19 deletions
diff --git a/middlewares/reqValidators/utils.js b/middlewares/reqValidators/utils.js
index c88f6df2e..46c982571 100644
--- a/middlewares/reqValidators/utils.js
+++ b/middlewares/reqValidators/utils.js
@@ -1,27 +1,25 @@
1;(function () { 1'use strict'
2 'use strict'
3 2
4 var util = require('util') 3var util = require('util')
5 4
6 var logger = require('../../helpers/logger') 5var logger = require('../../helpers/logger')
7 6
8 var reqValidatorsUtils = { 7var reqValidatorsUtils = {
9 checkErrors: checkErrors 8 checkErrors: checkErrors
10 } 9}
11
12 function checkErrors (req, res, next, status_code) {
13 if (status_code === undefined) status_code = 400
14 var errors = req.validationErrors()
15 10
16 if (errors) { 11function checkErrors (req, res, next, status_code) {
17 logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors }) 12 if (status_code === undefined) status_code = 400
18 return res.status(status_code).send('There have been validation errors: ' + util.inspect(errors)) 13 var errors = req.validationErrors()
19 }
20 14
21 return next() 15 if (errors) {
16 logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors })
17 return res.status(status_code).send('There have been validation errors: ' + util.inspect(errors))
22 } 18 }
23 19
24 // --------------------------------------------------------------------------- 20 return next()
21}
22
23// ---------------------------------------------------------------------------
25 24
26 module.exports = reqValidatorsUtils 25module.exports = reqValidatorsUtils
27})()