summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/dot/validate.jst
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/dot/validate.jst')
-rw-r--r--deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/dot/validate.jst184
1 files changed, 123 insertions, 61 deletions
diff --git a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/dot/validate.jst b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/dot/validate.jst
index 896e0860a4..4ebc599c06 100644
--- a/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/dot/validate.jst
+++ b/deps/npm/node_modules/request/node_modules/har-validator/node_modules/ajv/lib/dot/validate.jst
@@ -14,48 +14,93 @@
* validateRef etc. are defined in the parent scope in index.js
*/ }}
-{{ var $async = it.schema.$async === true; }}
+{{
+ var $async = it.schema.$async === true
+ , $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref')
+ , $id = it.self._getId(it.schema);
+}}
+
+{{? it.isTop }}
+ {{? $async }}
+ {{
+ it.async = true;
+ var $es7 = it.opts.async == 'es7';
+ it.yieldAwait = $es7 ? 'await' : 'yield';
+ }}
+ {{?}}
+
+ var validate =
+ {{? $async }}
+ {{? $es7 }}
+ (async function
+ {{??}}
+ {{? it.opts.async != '*'}}co.wrap{{?}}(function*
+ {{?}}
+ {{??}}
+ (function
+ {{?}}
+ (data, dataPath, parentData, parentDataProperty, rootData) {
+ 'use strict';
+ {{? $id && (it.opts.sourceCode || it.opts.processCode) }}
+ {{= '/\*# sourceURL=' + $id + ' */' }}
+ {{?}}
+{{?}}
-{{? it.isTop}}
+{{? typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref) }}
+ {{ var $keyword = 'false schema'; }}
+ {{# def.setupKeyword }}
+ {{? it.schema === false}}
+ {{? it.isTop}}
+ {{ $breakOnError = true; }}
+ {{??}}
+ var {{=$valid}} = false;
+ {{?}}
+ {{# def.error:'false schema' }}
+ {{??}}
+ {{? it.isTop}}
+ {{? $async }}
+ return data;
+ {{??}}
+ validate.errors = null;
+ return true;
+ {{?}}
+ {{??}}
+ var {{=$valid}} = true;
+ {{?}}
+ {{?}}
+
+ {{? it.isTop}}
+ });
+ return validate;
+ {{?}}
+
+ {{ return out; }}
+{{?}}
+
+
+{{? it.isTop }}
{{
var $top = it.isTop
, $lvl = it.level = 0
, $dataLvl = it.dataLevel = 0
, $data = 'data';
- it.rootId = it.resolve.fullPath(it.root.schema.id);
+ it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
it.baseId = it.baseId || it.rootId;
- if ($async) {
- it.async = true;
- var $es7 = it.opts.async == 'es7';
- it.yieldAwait = $es7 ? 'await' : 'yield';
- }
delete it.isTop;
it.dataPathArr = [undefined];
}}
- var validate =
- {{? $async }}
- {{? $es7 }}
- (async function
- {{??}}
- {{? it.opts.async == 'co*'}}co.wrap{{?}}(function*
- {{?}}
- {{??}}
- (function
- {{?}}
- (data, dataPath, parentData, parentDataProperty, rootData) {
- 'use strict';
- var vErrors = null; {{ /* don't edit, used in replace */ }}
- var errors = 0; {{ /* don't edit, used in replace */ }}
- if (rootData === undefined) rootData = data;
+ var vErrors = null; {{ /* don't edit, used in replace */ }}
+ var errors = 0; {{ /* don't edit, used in replace */ }}
+ if (rootData === undefined) rootData = data; {{ /* don't edit, used in replace */ }}
{{??}}
{{
var $lvl = it.level
, $dataLvl = it.dataLevel
, $data = 'data' + ($dataLvl || '');
- if (it.schema.id) it.baseId = it.resolve.url(it.baseId, it.schema.id);
+ if ($id) it.baseId = it.resolve.url(it.baseId, $id);
if ($async && !it.async) throw new Error('async schema in sync schema');
}}
@@ -72,6 +117,11 @@
var $errorKeyword;
var $typeSchema = it.schema.type
, $typeIsArray = Array.isArray($typeSchema);
+
+ if ($typeIsArray && $typeSchema.length == 1) {
+ $typeSchema = $typeSchema[0];
+ $typeIsArray = false;
+ }
}}
{{## def.checkType:
@@ -84,29 +134,40 @@
if ({{= it.util[$method]($typeSchema, $data, true) }}) {
#}}
-{{? $typeSchema && it.opts.coerceTypes }}
- {{ var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema); }}
- {{? $coerceToTypes }}
- {{# def.checkType }}
- {{# def.coerceType }}
- }
+{{? it.schema.$ref && $refKeywords }}
+ {{? it.opts.extendRefs == 'fail' }}
+ {{ throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)'); }}
+ {{?? it.opts.extendRefs !== true }}
+ {{
+ $refKeywords = false;
+ console.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
+ }}
{{?}}
{{?}}
-{{ var $refKeywords; }}
-{{? it.schema.$ref && ($refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, '$ref')) }}
- {{? it.opts.extendRefs == 'fail' }}
- {{ throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '"'); }}
- {{?? it.opts.extendRefs == 'ignore' }}
+{{? $typeSchema }}
+ {{? it.opts.coerceTypes }}
+ {{ var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema); }}
+ {{?}}
+
+ {{ var $rulesGroup = it.RULES.types[$typeSchema]; }}
+ {{? $coerceToTypes || $typeIsArray || $rulesGroup === true ||
+ ($rulesGroup && !$shouldUseGroup($rulesGroup)) }}
{{
- $refKeywords = false;
- console.log('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
+ var $schemaPath = it.schemaPath + '.type'
+ , $errSchemaPath = it.errSchemaPath + '/type';
}}
- {{?? it.opts.extendRefs !== true }}
- {{ console.log('$ref: all keywords used in schema at path "' + it.errSchemaPath + '". It will change in the next major version, see issue #260. Use option { extendRefs: true } to keep current behaviour'); }}
+ {{# def.checkType }}
+ {{? $coerceToTypes }}
+ {{# def.coerceType }}
+ {{??}}
+ {{# def.error:'type' }}
+ {{?}}
+ }
{{?}}
{{?}}
+
{{? it.schema.$ref && !$refKeywords }}
{{= it.RULES.all.$ref.code(it, '$ref') }}
{{? $breakOnError }}
@@ -115,6 +176,9 @@
{{ $closingBraces2 += '}'; }}
{{?}}
{{??}}
+ {{? it.opts.v5 && it.schema.patternGroups }}
+ {{ console.warn('keyword "patternGroups" is deprecated and disabled. Use option patternGroups: true to enable.'); }}
+ {{?}}
{{~ it.RULES:$rulesGroup }}
{{? $shouldUseGroup($rulesGroup) }}
{{? $rulesGroup.type }}
@@ -129,9 +193,12 @@
{{?}}
{{~ $rulesGroup.rules:$rule }}
{{? $shouldUseRule($rule) }}
- {{= $rule.code(it, $rule.keyword) }}
- {{? $breakOnError }}
- {{ $closingBraces1 += '}'; }}
+ {{ var $code = $rule.code(it, $rule.keyword, $rulesGroup.type); }}
+ {{? $code }}
+ {{= $code }}
+ {{? $breakOnError }}
+ {{ $closingBraces1 += '}'; }}
+ {{?}}
{{?}}
{{?}}
{{~}}
@@ -142,7 +209,6 @@
{{? $rulesGroup.type }}
}
{{? $typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes }}
- {{ var $typeChecked = true; }}
else {
{{
var $schemaPath = it.schemaPath + '.type'
@@ -161,17 +227,11 @@
{{~}}
{{?}}
-{{? $typeSchema && !$typeChecked && !$coerceToTypes }}
- {{# def.checkType }}
- {{# def.error:'type' }}
- }
-{{?}}
-
{{? $breakOnError }} {{= $closingBraces2 }} {{?}}
{{? $top }}
{{? $async }}
- if (errors === 0) return true; {{ /* don't edit, used in replace */ }}
+ if (errors === 0) return data; {{ /* don't edit, used in replace */ }}
else throw new ValidationError(vErrors); {{ /* don't edit, used in replace */ }}
{{??}}
validate.errors = vErrors; {{ /* don't edit, used in replace */ }}
@@ -186,25 +246,27 @@
{{# def.cleanUp }}
-{{? $top && $breakOnError }}
- {{# def.cleanUpVarErrors }}
+{{? $top }}
+ {{# def.finalCleanUp }}
{{?}}
{{
function $shouldUseGroup($rulesGroup) {
- for (var i=0; i < $rulesGroup.rules.length; i++)
- if ($shouldUseRule($rulesGroup.rules[i]))
+ var rules = $rulesGroup.rules;
+ for (var i=0; i < rules.length; i++)
+ if ($shouldUseRule(rules[i]))
return true;
}
function $shouldUseRule($rule) {
return it.schema[$rule.keyword] !== undefined ||
- ( $rule.keyword == 'properties' &&
- ( it.schema.additionalProperties === false ||
- typeof it.schema.additionalProperties == 'object'
- || ( it.schema.patternProperties &&
- Object.keys(it.schema.patternProperties).length )
- || ( it.opts.v5 && it.schema.patternGroups &&
- Object.keys(it.schema.patternGroups).length )));
+ ($rule.implements && $ruleImlementsSomeKeyword($rule));
+ }
+
+ function $ruleImlementsSomeKeyword($rule) {
+ var impl = $rule.implements;
+ for (var i=0; i < impl.length; i++)
+ if (it.schema[impl[i]] !== undefined)
+ return true;
}
}}