* Throws error when a required parameter is missing. * @param paramsObject The parameters passed to the function * @param paramsNeeded The required parameters in the function
(paramsObject: object, paramsNeeded: Array<string>)
| 534 | * @param paramsNeeded The required parameters in the function |
| 535 | */ |
| 536 | throwErrorOnWrongParams(paramsObject: object, paramsNeeded: Array<string>) { |
| 537 | const keys = Object.keys(paramsObject); |
| 538 | const bool = []; |
| 539 | for (let i = 0; i < keys.length; i++) { |
| 540 | if (paramsNeeded.includes(keys[i])) { |
| 541 | bool.push(true); |
| 542 | } else { |
| 543 | bool.push(false); |
| 544 | } |
| 545 | } |
| 546 | const truthy = (element: boolean) => element == false; |
| 547 | if (bool.some(truthy)) { |
| 548 | throw Error( |
| 549 | `Params Error: Required parameter not found. Your params must include the following [${paramsNeeded}]` |
| 550 | ); |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | /** |
| 555 | * Maps integer values (0, 1) to boolean (false, true) |
no test coverage detected