oBlazin

Untitled

Jan 23rd, 2022 (edited)
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Makes sure required fields are present
  2. if(Object.values(ticketInfo).includes(undefined)) {
  3.     var missingFields = [];
  4.     var ticketInfoFields = Object.keys(ticketInfo);
  5.     //Push all missing fields to the array
  6.     ticketInfoFields.forEach((element, index) => {
  7.         if(ticketInfo[element] == undefined) {
  8.             missingFields.push(Object.keys(ticketInfo)[index]);
  9.         }
  10.     });
  11.     //Create the string of missing fields for the result
  12.     var returnString = "Missing required fields: [".concat(missingFields.filter(function(el) {return el != null}).join(", "));
  13.     //Set properties of the result before returning
  14.     returnCode(400, res, ticketInfo, returnString, "]");
  15.     return;
  16. }
Add Comment
Please, Sign In to add comment