checking if input was valid before looking for suggestions

This commit is contained in:
Arjun Patel
2019-01-26 20:44:29 -08:00
parent 2bf26fccbf
commit 1aa0d2268a
@@ -11,6 +11,10 @@ const log10 = val => {
exports.findSuggested = (req, res, next) => {
const { amount, causes, regions } = req.body;
if (amount == 0 || causes.length == 0 || regions.length == 0) {
return next(errorMaker(400, 'Invalid options for grant suggestions'));
}
// formula for max amount of organizations to choose
const max_orgs = Math.floor(1.5 * log10(amount));