lib/middleware.js
function requireBody(paramsList) {
  return function (req, res, next) {
    var errors = [];
    var status = 'ok';

    for (var i = 0; i < paramsList.length; i++) {
      var val = req.body[paramsList[i]];

      if (!val) {
        errors.push(`required parameter \`${paramsList[i]}\` not found.`);
        status = 'error';
      }
    }

    if (errors.length === 0) {
      next();
    } else {
      return res.status(400).json({
        errors: errors,
        status: status
      });
    }
  };
}
function requireBody(paramsList) {
  return function (req, res, next) {
    var errors = [];
    var status = 'ok';

    for (var i = 0; i < paramsList.length; i++) {
      var val = req.body[paramsList[i]];

      if (!val) {
        errors.push(`required parameter \`${paramsList[i]}\` not found.`);
        status = 'error';
      }
    }

    if (errors.length === 0) {
      next();
    } else {
      return res.status(400).json({
        errors: errors,
        status: status
      });
    }
  };
}
function requireBody ( paramsList ) { return function ( req , res , next ) { var errors = [ ] ; var status = 'ok' ; for ( var i = 0 ; i < paramsList . length ; i ++ ) { var val = req . body [ paramsList [ i ] ] ; if ( ! val ) { errors . push ( ` \` ${ paramsList [ i ] } \` ` ) ; status = 'error' ; } } if ( errors . length === 0 ) { next ( ) ; } else { return res . status ( 400 ) . json ( { errors : errors , status : status } ) ; } } ; }
Require the specified req.body parameters, or else return a 400 with a descriptive JSON body
Require the specified req . body parameters or else return a 400 with a descriptive JSON body