Last change
on this file since b738035 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago |
primeNG components
|
-
Property mode
set to
100644
|
File size:
761 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var KEYWORDS = require('./keywords');
|
---|
| 4 |
|
---|
| 5 | module.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 | */
|
---|
| 14 | function 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 |
|
---|
| 29 | defineKeywords.get = get;
|
---|
| 30 |
|
---|
| 31 | function 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.