summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/node_modules/ajv-keywords/keywords/if.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/eslint/node_modules/ajv-keywords/keywords/if.js')
-rw-r--r--tools/node_modules/eslint/node_modules/ajv-keywords/keywords/if.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/ajv-keywords/keywords/if.js b/tools/node_modules/eslint/node_modules/ajv-keywords/keywords/if.js
new file mode 100644
index 0000000000..8a8fc95eeb
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/ajv-keywords/keywords/if.js
@@ -0,0 +1,21 @@
+'use strict';
+
+module.exports = function defFunc(ajv) {
+ if (!ajv.RULES.keywords.switch) require('./switch')(ajv);
+
+ defFunc.definition = {
+ macro: function (schema, parentSchema) {
+ if (parentSchema.then === undefined)
+ throw new Error('keyword "then" is absent');
+ var cases = [ { 'if': schema, 'then': parentSchema.then } ];
+ if (parentSchema.else !== undefined)
+ cases[1] = { 'then': parentSchema.else };
+ return { switch: cases };
+ }
+ };
+
+ ajv.addKeyword('if', defFunc.definition);
+ ajv.addKeyword('then');
+ ajv.addKeyword('else');
+ return ajv;
+};