diff options
Diffstat (limited to 'tools/node_modules/eslint/node_modules/ajv-keywords/keywords/typeof.js')
-rw-r--r-- | tools/node_modules/eslint/node_modules/ajv-keywords/keywords/typeof.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/ajv-keywords/keywords/typeof.js b/tools/node_modules/eslint/node_modules/ajv-keywords/keywords/typeof.js new file mode 100644 index 0000000000..3a3574d83f --- /dev/null +++ b/tools/node_modules/eslint/node_modules/ajv-keywords/keywords/typeof.js @@ -0,0 +1,32 @@ +'use strict'; + +var KNOWN_TYPES = ['undefined', 'string', 'number', 'object', 'function', 'boolean', 'symbol']; + +module.exports = function defFunc(ajv) { + defFunc.definition = { + inline: function (it, keyword, schema) { + var data = 'data' + (it.dataLevel || ''); + if (typeof schema == 'string') return 'typeof ' + data + ' == "' + schema + '"'; + schema = 'validate.schema' + it.schemaPath + '.' + keyword; + return schema + '.indexOf(typeof ' + data + ') >= 0'; + }, + metaSchema: { + anyOf: [ + { + type: 'string', + enum: KNOWN_TYPES + }, + { + type: 'array', + items: { + type: 'string', + enum: KNOWN_TYPES + } + } + ] + } + }; + + ajv.addKeyword('typeof', defFunc.definition); + return ajv; +}; |