-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathopen-x-htb-validator.js
89 lines (81 loc) · 2.77 KB
/
open-x-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
81
82
83
84
85
86
87
88
89
/**
* @author: Partner
* @license: UNLICENSED
*
* @copyright: Copyright (c) 2017 by Index Exchange. All rights reserved.
*
* The information contained within this document is confidential, copyrighted
* and or a trade secret. No part of this document may be reproduced or
* distributed in any form or by any means, in whole or in part, without the
* prior written permission of Index Exchange.
*/
'use strict';
////////////////////////////////////////////////////////////////////////////////
// Dependencies ////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
var Inspector = require('../../../libs/external/schema-inspector.js');
////////////////////////////////////////////////////////////////////////////////
// Main ////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
function partnerValidator(configs) {
var result = Inspector.validate({
type: 'object',
properties: {
host: {
type: 'string',
minLength: 1
},
medium: {
optional: true,
type: 'string',
minLength: 1
},
version: {
optional: true,
type: 'string',
minLength: 1
},
endPointName: {
optional: true,
type: 'string',
minLength: 1
},
charset: {
optional: true,
type: 'string',
minLength: 1
},
xSlots: {
type: 'object',
properties: {
'*': {
type: 'object',
properties: {
adUnitId: {
type: 'string',
minLength: 1
},
sizes: {
type: 'array',
minLength: 1,
items: {
type: 'array',
exactLength: 2,
items: {
type: 'integer',
gte: 0
}
}
}
}
}
}
}
}
}, configs);
if (!result.valid) {
return result.format();
}
return null;
}
module.exports = partnerValidator;