1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/packages/unleash-api/lib/error/validateRequest.js

16 lines
383 B
JavaScript
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
const BPromise = require('bluebird');
2016-06-18 21:53:18 +02:00
const ValidationError = require('./ValidationError');
2016-07-02 11:54:50 +02:00
function validateRequest (req) {
return new BPromise((resolve, reject) => {
if (req.validationErrors()) {
2016-06-18 21:55:46 +02:00
reject(new ValidationError('Invalid syntax'));
} else {
resolve(req);
}
});
}
module.exports = validateRequest;