-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathschema.js
71 lines (69 loc) · 2.51 KB
/
schema.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
const joi = require('joi')
const schema = joi.object().required().keys({
pages: joi.array().required().items(joi.object().keys({
path: joi.string().required(),
title: joi.string(),
condition: joi.string(),
section: joi.string(),
controller: joi.string(),
components: joi.array().required().items(joi.object().keys({
type: joi.string().required(),
name: joi.string(),
title: joi.string(),
hint: joi.string(),
options: joi.object().default({}),
schema: joi.object().default({})
}).unknown(true)),
next: joi.array().items(joi.object().keys({
path: joi.string().required(),
if: joi.string()
}))
})).unique('path'),
sections: joi.array().required().items(joi.object().keys({
name: joi.string().required(),
title: joi.string().required()
})).unique('name'),
conditions: joi.array().required().items(joi.object().keys({
name: joi.string().required(),
value: joi.string().required()
})).unique('name'),
lists: joi.array().required().items(joi.object().keys({
name: joi.string().required(),
title: joi.string().required(),
type: joi.string().required().valid('string', 'number'),
items: joi.alternatives().when('type', {
is: 'string',
then: joi.array().required().items(joi.object().keys({
text: joi.string().required(),
value: joi.string().required(),
description: joi.string().allow(''),
conditional: joi.object().keys({
components: joi.array().required().items(joi.object().keys({
type: joi.string().required(),
name: joi.string(),
title: joi.string(),
hint: joi.string(),
options: joi.object().default({}),
schema: joi.object().default({})
}).unknown(true)).unique('name')
})
})).unique('text').unique('value'),
otherwise: joi.array().required().items(joi.object().keys({
text: joi.string().required(),
value: joi.number().required(),
description: joi.string().allow(''),
conditional: joi.object().keys({
components: joi.array().required().items(joi.object().keys({
type: joi.string().required(),
name: joi.string(),
title: joi.string(),
hint: joi.string(),
options: joi.object().default({}),
schema: joi.object().default({})
}).unknown(true)).unique('name')
})
})).unique('text').unique('value')
})
})).unique('name')
})
module.exports = schema