2016-06-18 21:53:18 +02:00
|
|
|
'use strict';
|
2016-08-22 15:12:05 +02:00
|
|
|
const BPromise = require('bluebird');
|
2016-06-18 21:53:18 +02:00
|
|
|
const ValidationError = require('./ValidationError');
|
2014-12-10 18:45:02 +01:00
|
|
|
|
2016-07-02 11:54:50 +02:00
|
|
|
function validateRequest (req) {
|
2016-08-22 15:12:05 +02:00
|
|
|
return new BPromise((resolve, reject) => {
|
2014-12-10 18:45:02 +01:00
|
|
|
if (req.validationErrors()) {
|
2016-06-18 21:55:46 +02:00
|
|
|
reject(new ValidationError('Invalid syntax'));
|
2014-12-10 18:45:02 +01:00
|
|
|
} else {
|
|
|
|
resolve(req);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-04-24 22:41:37 +02:00
|
|
|
module.exports = validateRequest;
|