mirror of
https://github.com/thangisme/notes.git
synced 2026-07-28 05:13:48 -04:00
Initial commit
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function defFunc(ajv) {
|
||||
if (ajv.RULES.keywords.switch)
|
||||
return console.warn('Keyword switch is already defined');
|
||||
|
||||
var metaSchemaUri = ajv._opts.v5
|
||||
? 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#'
|
||||
: 'http://json-schema.org/draft-04/schema#';
|
||||
|
||||
defFunc.definition = {
|
||||
inline: require('./dotjs/switch'),
|
||||
statements: true,
|
||||
errors: 'full',
|
||||
metaSchema: {
|
||||
type: 'array',
|
||||
items: {
|
||||
required: [ 'then' ],
|
||||
properties: {
|
||||
'if': { $ref: metaSchemaUri },
|
||||
'then': {
|
||||
anyOf: [
|
||||
{ type: 'boolean' },
|
||||
{ $ref: metaSchemaUri }
|
||||
]
|
||||
},
|
||||
'continue': { type: 'boolean' }
|
||||
},
|
||||
additionalProperties: false,
|
||||
dependencies: {
|
||||
'continue': [ 'if' ]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ajv.addKeyword('switch', defFunc.definition);
|
||||
return ajv;
|
||||
};
|
||||
Reference in New Issue
Block a user