summaryrefslogtreecommitdiffstats
path: root/node_modules/ajv-keywords/index.js
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/ajv-keywords/index.js
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/ajv-keywords/index.js')
-rw-r--r--node_modules/ajv-keywords/index.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/node_modules/ajv-keywords/index.js b/node_modules/ajv-keywords/index.js
new file mode 100644
index 0000000..07a8eda
--- /dev/null
+++ b/node_modules/ajv-keywords/index.js
@@ -0,0 +1,35 @@
+'use strict';
+
+var KEYWORDS = require('./keywords');
+
+module.exports = defineKeywords;
+
+
+/**
+ * Defines one or several keywords in ajv instance
+ * @param {Ajv} ajv validator instance
+ * @param {String|Array<String>|undefined} keyword keyword(s) to define
+ * @return {Ajv} ajv instance (for chaining)
+ */
+function defineKeywords(ajv, keyword) {
+ if (Array.isArray(keyword)) {
+ for (var i=0; i<keyword.length; i++)
+ get(keyword[i])(ajv);
+ return ajv;
+ }
+ if (keyword) {
+ get(keyword)(ajv);
+ return ajv;
+ }
+ for (keyword in KEYWORDS) get(keyword)(ajv);
+ return ajv;
+}
+
+
+defineKeywords.get = get;
+
+function get(keyword) {
+ var defFunc = KEYWORDS[keyword];
+ if (!defFunc) throw new Error('Unknown keyword ' + keyword);
+ return defFunc;
+}