function validateReqBody(req) {
  const contype = req.headers['content-type'];
  if (!contype || contype.indexOf('application/json') !== 0) {
    throw new Error('Invalid content-type');
  }
  //check if req body is empty
  if (_.isEmpty(req.body)) {
    throw new Error('Rquest Body is Empty')
  }
  //check if payload exists
  if (!req.body.payload) {
    throw new Error('Payload field is missing');
  }
  //check if payload length is zero
  if (req.body.payload.length === 0) {
    throw new Error('Payload length is 0');
  }
  return;
}
/**
Function does basic validation on the request body
to check if the request body is vali
This function is called recursively until all the elements in the 
payload array are processed.
*/
Function does basic validation on the request body
to check if the request body is vali
This function is called recursively until all the elements in the
payload array are processed.
Function does basic validation on the request body to check if the request body is vali This function is called recursively until all the elements in the payload array are processed .
function validateReqBody(req) {
  const contype = req.headers['content-type'];
  if (!contype || contype.indexOf('application/json') !== 0) {
    throw new Error('Invalid content-type');
  }
  if (_.isEmpty(req.body)) {
    throw new Error('Rquest Body is Empty')
  }
  if (!req.body.payload) {
    throw new Error('Payload field is missing');
  }
  if (req.body.payload.length === 0) {
    throw new Error('Payload length is 0');
  }
  return;
}
function validateReqBody ( req ) { const contype = req . headers [ 'content-type' ] ; if ( ! contype || contype . indexOf ( 'application/json' ) !== 0 ) { throw new Error ( 'Invalid content-type' ) ; } if ( _ . isEmpty ( req . body ) ) { throw new Error ( 'Rquest Body is Empty' ) } if ( ! req . body . payload ) { throw new Error ( 'Payload field is missing' ) ; } if ( req . body . payload . length === 0 ) { throw new Error ( 'Payload length is 0' ) ; } return ; }
Function does basic validation on the request body
to check if the request body is vali
This function is called recursively until all the elements in the
payload array are processed.
Function does basic validation on the request body to check if the request body is vali This function is called recursively until all the elements in the payload array are processed .
//check if req body is empty //check if payload exists //check if payload length is zero