diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 |
commit | de98e0b232509d5f40c135d540a70e415272ff85 (patch) | |
tree | a79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/ajv/lib/v5.js | |
parent | e0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff) | |
download | wallet-core-de98e0b232509d5f40c135d540a70e415272ff85.tar.xz |
node_modules
Diffstat (limited to 'node_modules/ajv/lib/v5.js')
-rw-r--r-- | node_modules/ajv/lib/v5.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/node_modules/ajv/lib/v5.js b/node_modules/ajv/lib/v5.js new file mode 100644 index 000000000..8f6e53f0f --- /dev/null +++ b/node_modules/ajv/lib/v5.js @@ -0,0 +1,52 @@ +'use strict'; + +var META_SCHEMA_ID = 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json'; + +module.exports = { + enable: enableV5, + META_SCHEMA_ID: META_SCHEMA_ID +}; + + +function enableV5(ajv) { + var inlineFunctions = { + 'switch': require('./dotjs/switch'), + 'constant': require('./dotjs/constant'), + '_formatLimit': require('./dotjs/_formatLimit'), + 'patternRequired': require('./dotjs/patternRequired') + }; + + if (ajv._opts.meta !== false) { + var metaSchema = require('./refs/json-schema-v5.json'); + ajv.addMetaSchema(metaSchema, META_SCHEMA_ID); + } + _addKeyword('constant'); + ajv.addKeyword('contains', { type: 'array', macro: containsMacro }); + + _addKeyword('formatMaximum', 'string', inlineFunctions._formatLimit); + _addKeyword('formatMinimum', 'string', inlineFunctions._formatLimit); + ajv.addKeyword('formatExclusiveMaximum'); + ajv.addKeyword('formatExclusiveMinimum'); + + ajv.addKeyword('patternGroups'); // implemented in properties.jst + _addKeyword('patternRequired', 'object'); + _addKeyword('switch'); + + + function _addKeyword(keyword, types, inlineFunc) { + var definition = { + inline: inlineFunc || inlineFunctions[keyword], + statements: true, + errors: 'full' + }; + if (types) definition.type = types; + ajv.addKeyword(keyword, definition); + } +} + + +function containsMacro(schema) { + return { + not: { items: { not: schema } } + }; +} |