-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconsumable-htb-validator.js
80 lines (73 loc) · 3.02 KB
/
consumable-htb-validator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'use strict';
////////////////////////////////////////////////////////////////////////////////
// Dependencies ////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
var Inspector = require('../../../libs/external/schema-inspector.js');
////////////////////////////////////////////////////////////////////////////////
// Main ////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/* =============================================================================
* STEP 0 | Config Validation
* -----------------------------------------------------------------------------
* This file contains the necessary validation for the partner configuration.
* This validation will be performed on the partner specific configuration object
* that is passed into the wrapper. The wrapper uses an outside library called
* schema-insepctor to perform the validation. Information about it can be found here:
* https://atinux.fr/schema-inspector/.
*/
function partnerValidator(configs) {
var result = Inspector.validate({
type: 'object',
properties: {
xSlots: {
type: 'object',
properties: {
'*': {
type: 'object',
properties: {
networkId: {
type: 'string',
minLength: 1
},
siteId: {
type: 'string',
minLength: 1
},
zoneIds: {
type: 'array',
optional: true,
items: {
type: 'number'
}
},
unitId: {
type: 'string',
minLength: 1
},
unitName: {
type: 'string',
minLength: 1
},
sizes: {
type: 'array',
minLength: 1,
items: {
type: 'array',
exactLength: 2,
items: {
type: 'number'
}
}
}
}
}
}
}
}
}, configs);
if (!result.valid) {
return result.format();
}
return null;
}
module.exports = partnerValidator;