1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.validateDuplicateKeys = exports.validateMapElementNotNull = exports.validateArrayElementsNotNull = exports.validateNotNull = void 0;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function validateNotNull(reference, errorMessage) {
|
28 | if (reference === null || reference === undefined) {
|
29 | throw new Error(`Missing mandatory ${errorMessage} parameter`);
|
30 | }
|
31 | return reference;
|
32 | }
|
33 | exports.validateNotNull = validateNotNull;
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | function validateArrayElementsNotNull(array, errorMessage) {
|
41 | const areAllDefined = array.every(element => element !== null && typeof element !== 'undefined');
|
42 | if (!areAllDefined) {
|
43 | throw new Error(`${errorMessage} elements should not be a NULL`);
|
44 | }
|
45 | }
|
46 | exports.validateArrayElementsNotNull = validateArrayElementsNotNull;
|
47 |
|
48 | function validateMapElementNotNull(map, errorMessage) {
|
49 | for (const [key, value] of map.entries()) {
|
50 | if (key == null || value == null) {
|
51 | throw new Error(`${errorMessage} elements should not be a NULL`);
|
52 | }
|
53 | }
|
54 | }
|
55 | exports.validateMapElementNotNull = validateMapElementNotNull;
|
56 |
|
57 | function validateDuplicateKeys(keys, constantLabels) {
|
58 | const keysAndConstantKeys = new Set([...keys, ...constantLabels.keys()].map(k => k.key));
|
59 | if (keysAndConstantKeys.size !== keys.length + constantLabels.size) {
|
60 | throw new Error(`The keys from LabelKeys should not be present in constantLabels or LabelKeys should not contains duplicate keys`);
|
61 | }
|
62 | }
|
63 | exports.validateDuplicateKeys = validateDuplicateKeys;
|
64 |
|
\ | No newline at end of file |