Sha256: 6a08997766a8fb9516f159e7110836ae36dcd75df34766c908f68e3f2cd27aeb
Contents?: true
Size: 761 Bytes
Versions: 177
Compression:
Stored size: 761 Bytes
Contents
'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; }
Version data entries
177 entries across 80 versions & 15 rubygems