1
|
'use strict';
|
2
|
|
3
|
var util = require('./_util');
|
4
|
|
5
|
module.exports = function defFunc(ajv) {
|
6
|
if (ajv.RULES.keywords.switch && ajv.RULES.keywords.if) return;
|
7
|
|
8
|
var metaSchemaRef = util.metaSchemaRef(ajv);
|
9
|
|
10
|
defFunc.definition = {
|
11
|
inline: require('./dotjs/switch'),
|
12
|
statements: true,
|
13
|
errors: 'full',
|
14
|
metaSchema: {
|
15
|
type: 'array',
|
16
|
items: {
|
17
|
required: [ 'then' ],
|
18
|
properties: {
|
19
|
'if': metaSchemaRef,
|
20
|
'then': {
|
21
|
anyOf: [
|
22
|
{ type: 'boolean' },
|
23
|
metaSchemaRef
|
24
|
]
|
25
|
},
|
26
|
'continue': { type: 'boolean' }
|
27
|
},
|
28
|
additionalProperties: false,
|
29
|
dependencies: {
|
30
|
'continue': [ 'if' ]
|
31
|
}
|
32
|
}
|
33
|
}
|
34
|
};
|
35
|
|
36
|
ajv.addKeyword('switch', defFunc.definition);
|
37
|
return ajv;
|
38
|
};
|