source: trip-planner-front/node_modules/ajv-keywords/index.js@ 1ad8e64

Last change on this file since 1ad8e64 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 761 bytes
Line 
1'use strict';
2
3var KEYWORDS = require('./keywords');
4
5module.exports = defineKeywords;
6
7
8/**
9 * Defines one or several keywords in ajv instance
10 * @param {Ajv} ajv validator instance
11 * @param {String|Array<String>|undefined} keyword keyword(s) to define
12 * @return {Ajv} ajv instance (for chaining)
13 */
14function defineKeywords(ajv, keyword) {
15 if (Array.isArray(keyword)) {
16 for (var i=0; i<keyword.length; i++)
17 get(keyword[i])(ajv);
18 return ajv;
19 }
20 if (keyword) {
21 get(keyword)(ajv);
22 return ajv;
23 }
24 for (keyword in KEYWORDS) get(keyword)(ajv);
25 return ajv;
26}
27
28
29defineKeywords.get = get;
30
31function get(keyword) {
32 var defFunc = KEYWORDS[keyword];
33 if (!defFunc) throw new Error('Unknown keyword ' + keyword);
34 return defFunc;
35}
Note: See TracBrowser for help on using the repository browser.