-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlayer-group.js
52 lines (48 loc) · 1.15 KB
/
layer-group.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
const Joi = require('joi');
const layerSchema = require('./layer');
const legendIconSchema = Joi.object().keys({
type: Joi.string().valid(
'line',
'rectangle',
'fa-icon',
'square-hatch',
).required(),
layers: Joi.when('type', {
is: 'fa-icon',
then: Joi.array().items(
Joi.object().keys({
'fa-icon': Joi.string().required(),
}).unknown(),
),
otherwise: Joi.array().items(Joi.object()),
}),
});
const legendItemSchema = Joi.object().keys({
label: Joi.string().required(),
tooltip: Joi.string(),
icon: legendIconSchema,
});
module.exports = Joi.object().keys({
id: Joi.string().required(),
visible: Joi.boolean(),
filter: Joi.array(),
title: Joi.string(),
titleTooltip: Joi.string(),
legend: Joi.object().keys({
label: Joi.string().required(),
tooltip: Joi.string(),
infolink: Joi.string(),
icon: legendIconSchema,
items: Joi.array().items(
legendItemSchema,
),
}),
layerVisibilityType: Joi.string(),
meta: Joi.object(),
layers: Joi.array().items(
layerSchema,
),
legendConfig: Joi.object(),
legendIcon: Joi.string(),
legendColor: Joi.string(),
});