daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Aug 12th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function checkParams(params){   //params is an object with key/value pairs
  2.  
  3.   var name, value,
  4.       errCode, errMsg;
  5.   f:for (name in params){
  6.     s:switch (name) {
  7.       case 'param1':
  8.         if (...params[name] valid...) {
  9.           break s;
  10.         }
  11.         errCode = 1;
  12.         errMsg = 'Whoops, error in param ' + name;
  13.         break f;
  14.       case ...etc...
  15.         ...many more cases...
  16.     }
  17.   }
  18.   if (errCode) {
  19.     throw {
  20.       code: errCode,
  21.       msg: errMsg
  22.     };
  23.   }
  24. }
RAW Paste Data
Top