| Conditions | 8 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | class Validate { |
||
| 35 | paramConfiguration (input, callback) { |
||
| 36 | let error = null |
||
| 37 | |||
| 38 | if (!input.hasOwnProperty('params')) { |
||
| 39 | if (!error) { |
||
| 40 | return error = new Error('The parameters are not been set.') |
||
| 41 | } |
||
| 42 | } else { |
||
| 43 | if (!input.params.topic) { |
||
| 44 | if (!error) { |
||
| 45 | error = new Error('The parameter topic has not been set.') |
||
| 46 | } |
||
| 47 | } |
||
| 48 | if (!input.params.payload) { |
||
| 49 | if (!error) { |
||
| 50 | error = new Error('The parameter payload has not been set.') |
||
| 51 | } |
||
| 52 | } |
||
| 53 | |||
| 54 | if (![0, 1, 2].includes(input.params.qos)) { |
||
| 55 | input.params.qos = 1 |
||
| 56 | } else { |
||
| 57 | input.params.qos.toString() |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | callback(input, error) |
||
| 62 | } |
||
| 63 | |||
| 67 |