summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/ajv/lib/compile/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/ajv/lib/compile/rules.js')
-rw-r--r--deps/npm/node_modules/ajv/lib/compile/rules.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/deps/npm/node_modules/ajv/lib/compile/rules.js b/deps/npm/node_modules/ajv/lib/compile/rules.js
new file mode 100644
index 0000000000..44830ad72d
--- /dev/null
+++ b/deps/npm/node_modules/ajv/lib/compile/rules.js
@@ -0,0 +1,58 @@
+'use strict';
+
+var ruleModules = require('./_rules')
+ , toHash = require('./util').toHash;
+
+module.exports = function rules() {
+ var RULES = [
+ { type: 'number',
+ rules: [ { 'maximum': ['exclusiveMaximum'] },
+ { 'minimum': ['exclusiveMinimum'] }, 'multipleOf', 'format'] },
+ { type: 'string',
+ rules: [ 'maxLength', 'minLength', 'pattern', 'format' ] },
+ { type: 'array',
+ rules: [ 'maxItems', 'minItems', 'uniqueItems', 'contains', 'items' ] },
+ { type: 'object',
+ rules: [ 'maxProperties', 'minProperties', 'required', 'dependencies', 'propertyNames',
+ { 'properties': ['additionalProperties', 'patternProperties'] } ] },
+ { rules: [ '$ref', 'const', 'enum', 'not', 'anyOf', 'oneOf', 'allOf' ] }
+ ];
+
+ var ALL = [ 'type' ];
+ var KEYWORDS = [
+ 'additionalItems', '$schema', '$id', 'id', 'title',
+ 'description', 'default', 'definitions'
+ ];
+ var TYPES = [ 'number', 'integer', 'string', 'array', 'object', 'boolean', 'null' ];
+ RULES.all = toHash(ALL);
+ RULES.types = toHash(TYPES);
+
+ RULES.forEach(function (group) {
+ group.rules = group.rules.map(function (keyword) {
+ var implKeywords;
+ if (typeof keyword == 'object') {
+ var key = Object.keys(keyword)[0];
+ implKeywords = keyword[key];
+ keyword = key;
+ implKeywords.forEach(function (k) {
+ ALL.push(k);
+ RULES.all[k] = true;
+ });
+ }
+ ALL.push(keyword);
+ var rule = RULES.all[keyword] = {
+ keyword: keyword,
+ code: ruleModules[keyword],
+ implements: implKeywords
+ };
+ return rule;
+ });
+
+ if (group.type) RULES.types[group.type] = group;
+ });
+
+ RULES.keywords = toHash(ALL.concat(KEYWORDS));
+ RULES.custom = {};
+
+ return RULES;
+};