aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ajv/lib/dot
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ajv/lib/dot')
-rw-r--r--node_modules/ajv/lib/dot/_limit.jst8
-rw-r--r--node_modules/ajv/lib/dot/custom.jst4
-rw-r--r--node_modules/ajv/lib/dot/errors.def12
-rw-r--r--node_modules/ajv/lib/dot/format.jst4
-rw-r--r--node_modules/ajv/lib/dot/oneOf.jst24
-rw-r--r--node_modules/ajv/lib/dot/properties.jst89
-rw-r--r--node_modules/ajv/lib/dot/ref.jst4
-rw-r--r--node_modules/ajv/lib/dot/uniqueItems.jst42
-rw-r--r--node_modules/ajv/lib/dot/validate.jst37
9 files changed, 83 insertions, 141 deletions
diff --git a/node_modules/ajv/lib/dot/_limit.jst b/node_modules/ajv/lib/dot/_limit.jst
index 13e7649b3..e10806fd3 100644
--- a/node_modules/ajv/lib/dot/_limit.jst
+++ b/node_modules/ajv/lib/dot/_limit.jst
@@ -50,6 +50,14 @@
)
|| {{=$data}} !== {{=$data}}) {
var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
+ {{
+ if ($schema === undefined) {
+ $errorKeyword = $exclusiveKeyword;
+ $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
+ $schemaValue = $schemaValueExcl;
+ $isData = $isDataExcl;
+ }
+ }}
{{??}}
{{
var $exclIsNumber = typeof $schemaExcl == 'number'
diff --git a/node_modules/ajv/lib/dot/custom.jst b/node_modules/ajv/lib/dot/custom.jst
index 402028e6b..d30588fb0 100644
--- a/node_modules/ajv/lib/dot/custom.jst
+++ b/node_modules/ajv/lib/dot/custom.jst
@@ -112,13 +112,13 @@ var {{=$valid}};
{{# def.storeDefOut:def_callRuleValidate }}
{{? $rDef.errors === false }}
- {{=$valid}} = {{? $asyncKeyword }}{{=it.yieldAwait}}{{?}}{{= def_callRuleValidate }};
+ {{=$valid}} = {{? $asyncKeyword }}await {{?}}{{= def_callRuleValidate }};
{{??}}
{{? $asyncKeyword }}
{{ $ruleErrs = 'customErrors' + $lvl; }}
var {{=$ruleErrs}} = null;
try {
- {{=$valid}} = {{=it.yieldAwait}}{{= def_callRuleValidate }};
+ {{=$valid}} = await {{= def_callRuleValidate }};
} catch (e) {
{{=$valid}} = false;
if (e instanceof ValidationError) {{=$ruleErrs}} = e.errors;
diff --git a/node_modules/ajv/lib/dot/errors.def b/node_modules/ajv/lib/dot/errors.def
index b79646fc2..4d7f84840 100644
--- a/node_modules/ajv/lib/dot/errors.def
+++ b/node_modules/ajv/lib/dot/errors.def
@@ -94,13 +94,14 @@
'false schema': "'boolean schema is false'",
$ref: "'can\\\'t resolve reference {{=it.util.escapeQuotes($schema)}}'",
additionalItems: "'should NOT have more than {{=$schema.length}} items'",
- additionalProperties: "'should NOT have additional properties'",
+ additionalProperties: "'{{? it.opts._errorDataPathProperty }}is an invalid additional property{{??}}should NOT have additional properties{{?}}'",
anyOf: "'should match some schema in anyOf'",
const: "'should be equal to constant'",
contains: "'should contain a valid item'",
dependencies: "'should have {{? $deps.length == 1 }}property {{= it.util.escapeQuotes($deps[0]) }}{{??}}properties {{= it.util.escapeQuotes($deps.join(\", \")) }}{{?}} when property {{= it.util.escapeQuotes($property) }} is present'",
'enum': "'should be equal to one of the allowed values'",
format: "'should match format \"{{#def.concatSchemaEQ}}\"'",
+ 'if': "'should match \"' + {{=$ifClause}} + '\" schema'",
_limit: "'should be {{=$opStr}} {{#def.appendSchema}}",
_exclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'",
_limitItems: "'should NOT have {{?$keyword=='maxItems'}}more{{??}}less{{?}} than {{#def.concatSchema}} items'",
@@ -110,7 +111,6 @@
not: "'should NOT be valid'",
oneOf: "'should match exactly one schema in oneOf'",
pattern: "'should match pattern \"{{#def.concatSchemaEQ}}\"'",
- patternGroups: "'should NOT have {{=$moreOrLess}} than {{=$limit}} properties matching pattern \"{{=it.util.escapeQuotes($pgProperty)}}\"'",
propertyNames: "'property name \\'{{=$invalidName}}\\' is invalid'",
required: "'{{? it.opts._errorDataPathProperty }}is a required property{{??}}should have required property \\'{{=$missingProperty}}\\'{{?}}'",
type: "'should be {{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}'",
@@ -137,6 +137,7 @@
dependencies: "validate.schema{{=$schemaPath}}",
'enum': "validate.schema{{=$schemaPath}}",
format: "{{#def.schemaRefOrQS}}",
+ 'if': "validate.schema{{=$schemaPath}}",
_limit: "{{#def.schemaRefOrVal}}",
_exclusiveLimit: "validate.schema{{=$schemaPath}}",
_limitItems: "{{#def.schemaRefOrVal}}",
@@ -146,7 +147,6 @@
not: "validate.schema{{=$schemaPath}}",
oneOf: "validate.schema{{=$schemaPath}}",
pattern: "{{#def.schemaRefOrQS}}",
- patternGroups: "validate.schema{{=$schemaPath}}",
propertyNames: "validate.schema{{=$schemaPath}}",
required: "validate.schema{{=$schemaPath}}",
type: "validate.schema{{=$schemaPath}}",
@@ -167,11 +167,12 @@
additionalItems: "{ limit: {{=$schema.length}} }",
additionalProperties: "{ additionalProperty: '{{=$additionalProperty}}' }",
anyOf: "{}",
- const: "{}",
+ const: "{ allowedValue: schema{{=$lvl}} }",
contains: "{}",
dependencies: "{ property: '{{= it.util.escapeQuotes($property) }}', missingProperty: '{{=$missingProperty}}', depsCount: {{=$deps.length}}, deps: '{{= it.util.escapeQuotes($deps.length==1 ? $deps[0] : $deps.join(\", \")) }}' }",
'enum': "{ allowedValues: schema{{=$lvl}} }",
format: "{ format: {{#def.schemaValueQS}} }",
+ 'if': "{ failingKeyword: {{=$ifClause}} }",
_limit: "{ comparison: {{=$opExpr}}, limit: {{=$schemaValue}}, exclusive: {{=$exclusive}} }",
_exclusiveLimit: "{}",
_limitItems: "{ limit: {{=$schemaValue}} }",
@@ -179,9 +180,8 @@
_limitProperties:"{ limit: {{=$schemaValue}} }",
multipleOf: "{ multipleOf: {{=$schemaValue}} }",
not: "{}",
- oneOf: "{}",
+ oneOf: "{ passingSchemas: {{=$passingSchemas}} }",
pattern: "{ pattern: {{#def.schemaValueQS}} }",
- patternGroups: "{ reason: '{{=$reason}}', limit: {{=$limit}}, pattern: '{{=it.util.escapeQuotes($pgProperty)}}' }",
propertyNames: "{ propertyName: '{{=$invalidName}}' }",
required: "{ missingProperty: '{{=$missingProperty}}' }",
type: "{ type: '{{? $typeIsArray }}{{= $typeSchema.join(\",\") }}{{??}}{{=$typeSchema}}{{?}}' }",
diff --git a/node_modules/ajv/lib/dot/format.jst b/node_modules/ajv/lib/dot/format.jst
index 484dddf79..37f14da80 100644
--- a/node_modules/ajv/lib/dot/format.jst
+++ b/node_modules/ajv/lib/dot/format.jst
@@ -24,7 +24,7 @@
({{=$format}} && {{=$formatType}} == '{{=$ruleType}}'
&& !(typeof {{=$format}} == 'function'
? {{? it.async}}
- (async{{=$lvl}} ? {{=it.yieldAwait}} {{=$format}}({{=$data}}) : {{=$format}}({{=$data}}))
+ (async{{=$lvl}} ? await {{=$format}}({{=$data}}) : {{=$format}}({{=$data}}))
{{??}}
{{=$format}}({{=$data}})
{{?}}
@@ -97,7 +97,7 @@
if (!it.async) throw new Error('async format in sync schema');
var $formatRef = 'formats' + it.util.getProperty($schema) + '.validate';
}}
- if (!({{=it.yieldAwait}} {{=$formatRef}}({{=$data}}))) {
+ if (!(await {{=$formatRef}}({{=$data}}))) {
{{??}}
if (!{{# def.checkFormat }}) {
{{?}}
diff --git a/node_modules/ajv/lib/dot/oneOf.jst b/node_modules/ajv/lib/dot/oneOf.jst
index 59a435549..bcce2c6ed 100644
--- a/node_modules/ajv/lib/dot/oneOf.jst
+++ b/node_modules/ajv/lib/dot/oneOf.jst
@@ -3,11 +3,17 @@
{{# def.setupKeyword }}
{{# def.setupNextLevel }}
-var {{=$errs}} = errors;
-var prevValid{{=$lvl}} = false;
-var {{=$valid}} = false;
+{{
+ var $currentBaseId = $it.baseId
+ , $prevValid = 'prevValid' + $lvl
+ , $passingSchemas = 'passingSchemas' + $lvl;
+}}
+
+var {{=$errs}} = errors
+ , {{=$prevValid}} = false
+ , {{=$valid}} = false
+ , {{=$passingSchemas}} = null;
-{{ var $currentBaseId = $it.baseId; }}
{{# def.setCompositeRule }}
{{~ $schema:$sch:$i }}
@@ -24,13 +30,17 @@ var {{=$valid}} = false;
{{?}}
{{? $i }}
- if ({{=$nextValid}} && prevValid{{=$lvl}})
+ if ({{=$nextValid}} && {{=$prevValid}}) {
{{=$valid}} = false;
- else {
+ {{=$passingSchemas}} = [{{=$passingSchemas}}, {{=$i}}];
+ } else {
{{ $closingBraces += '}'; }}
{{?}}
- if ({{=$nextValid}}) {{=$valid}} = prevValid{{=$lvl}} = true;
+ if ({{=$nextValid}}) {
+ {{=$valid}} = {{=$prevValid}} = true;
+ {{=$passingSchemas}} = {{=$i}};
+ }
{{~}}
{{# def.resetCompositeRule }}
diff --git a/node_modules/ajv/lib/dot/properties.jst b/node_modules/ajv/lib/dot/properties.jst
index 8d56324b7..862067e75 100644
--- a/node_modules/ajv/lib/dot/properties.jst
+++ b/node_modules/ajv/lib/dot/properties.jst
@@ -42,13 +42,8 @@
, $currentBaseId = it.baseId;
var $required = it.schema.required;
- if ($required && !(it.opts.v5 && $required.$data) && $required.length < it.opts.loopRequired)
+ if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired)
var $requiredHash = it.util.toHash($required);
-
- if (it.opts.patternGroups) {
- var $pgProperties = it.schema.patternGroups || {}
- , $pgPropertyKeys = Object.keys($pgProperties);
- }
}}
@@ -63,8 +58,8 @@ var {{=$nextValid}} = true;
{{? $someProperties }}
var isAdditional{{=$lvl}} = !(false
{{? $schemaKeys.length }}
- {{? $schemaKeys.length > 5 }}
- || validate.schema{{=$schemaPath}}[{{=$key}}]
+ {{? $schemaKeys.length > 8 }}
+ || validate.schema{{=$schemaPath}}.hasOwnProperty({{=$key}})
{{??}}
{{~ $schemaKeys:$propertyKey }}
|| {{=$key}} == {{= it.util.toQuotedString($propertyKey) }}
@@ -76,11 +71,6 @@ var {{=$nextValid}} = true;
|| {{= it.usePattern($pProperty) }}.test({{=$key}})
{{~}}
{{?}}
- {{? it.opts.patternGroups && $pgPropertyKeys.length }}
- {{~ $pgPropertyKeys:$pgProperty:$i }}
- || {{= it.usePattern($pgProperty) }}.test({{=$key}})
- {{~}}
- {{?}}
);
if (isAdditional{{=$lvl}}) {
@@ -246,79 +236,6 @@ var {{=$nextValid}} = true;
{{?}}
-{{? it.opts.patternGroups && $pgPropertyKeys.length }}
- {{~ $pgPropertyKeys:$pgProperty }}
- {{
- var $pgSchema = $pgProperties[$pgProperty]
- , $sch = $pgSchema.schema;
- }}
-
- {{? {{# def.nonEmptySchema:$sch}} }}
- {{
- $it.schema = $sch;
- $it.schemaPath = it.schemaPath + '.patternGroups' + it.util.getProperty($pgProperty) + '.schema';
- $it.errSchemaPath = it.errSchemaPath + '/patternGroups/'
- + it.util.escapeFragment($pgProperty)
- + '/schema';
- }}
-
- var pgPropCount{{=$lvl}} = 0;
-
- {{# def.iterateProperties }}
- if ({{= it.usePattern($pgProperty) }}.test({{=$key}})) {
- pgPropCount{{=$lvl}}++;
-
- {{
- $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
- var $passData = $data + '[' + $key + ']';
- $it.dataPathArr[$dataNxt] = $key;
- }}
-
- {{# def.generateSubschemaCode }}
- {{# def.optimizeValidate }}
-
- {{? $breakOnError }} if (!{{=$nextValid}}) break; {{?}}
- }
- {{? $breakOnError }} else {{=$nextValid}} = true; {{?}}
- }
-
- {{# def.ifResultValid }}
-
- {{
- var $pgMin = $pgSchema.minimum
- , $pgMax = $pgSchema.maximum;
- }}
- {{? $pgMin !== undefined || $pgMax !== undefined }}
- var {{=$valid}} = true;
-
- {{ var $currErrSchemaPath = $errSchemaPath; }}
-
- {{? $pgMin !== undefined }}
- {{ var $limit = $pgMin, $reason = 'minimum', $moreOrLess = 'less'; }}
- {{=$valid}} = pgPropCount{{=$lvl}} >= {{=$pgMin}};
- {{ $errSchemaPath = it.errSchemaPath + '/patternGroups/minimum'; }}
- {{# def.checkError:'patternGroups' }}
- {{? $pgMax !== undefined }}
- else
- {{?}}
- {{?}}
-
- {{? $pgMax !== undefined }}
- {{ var $limit = $pgMax, $reason = 'maximum', $moreOrLess = 'more'; }}
- {{=$valid}} = pgPropCount{{=$lvl}} <= {{=$pgMax}};
- {{ $errSchemaPath = it.errSchemaPath + '/patternGroups/maximum'; }}
- {{# def.checkError:'patternGroups' }}
- {{?}}
-
- {{ $errSchemaPath = $currErrSchemaPath; }}
-
- {{# def.ifValid }}
- {{?}}
- {{?}} {{ /* def.nonEmptySchema */ }}
- {{~}}
-{{?}}
-
-
{{? $breakOnError }}
{{= $closingBraces }}
if ({{=$errs}} == errors) {
diff --git a/node_modules/ajv/lib/dot/ref.jst b/node_modules/ajv/lib/dot/ref.jst
index 036bc2905..253e3507c 100644
--- a/node_modules/ajv/lib/dot/ref.jst
+++ b/node_modules/ajv/lib/dot/ref.jst
@@ -50,7 +50,7 @@
{{?}}
{{??}}
{{
- $async = $refVal.$async === true;
+ $async = $refVal.$async === true || (it.async && $refVal.$async !== false);
$refCode = $refVal.code;
}}
{{?}}
@@ -65,7 +65,7 @@
{{ if (!it.async) throw new Error('async schema referenced by sync schema'); }}
{{? $breakOnError }} var {{=$valid}}; {{?}}
try {
- {{=it.yieldAwait}} {{=__callValidate}};
+ await {{=__callValidate}};
{{? $breakOnError }} {{=$valid}} = true; {{?}}
} catch (e) {
if (!(e instanceof ValidationError)) throw e;
diff --git a/node_modules/ajv/lib/dot/uniqueItems.jst b/node_modules/ajv/lib/dot/uniqueItems.jst
index dfc42b03b..22f82f99d 100644
--- a/node_modules/ajv/lib/dot/uniqueItems.jst
+++ b/node_modules/ajv/lib/dot/uniqueItems.jst
@@ -14,18 +14,42 @@
else {
{{?}}
- var {{=$valid}} = true;
- if ({{=$data}}.length > 1) {
- var i = {{=$data}}.length, j;
- outer:
- for (;i--;) {
- for (j = i; j--;) {
- if (equal({{=$data}}[i], {{=$data}}[j])) {
+ var i = {{=$data}}.length
+ , {{=$valid}} = true
+ , j;
+ if (i > 1) {
+ {{
+ var $itemType = it.schema.items && it.schema.items.type
+ , $typeIsArray = Array.isArray($itemType);
+ }}
+ {{? !$itemType || $itemType == 'object' || $itemType == 'array' ||
+ ($typeIsArray && ($itemType.indexOf('object') >= 0 || $itemType.indexOf('array') >= 0)) }}
+ outer:
+ for (;i--;) {
+ for (j = i; j--;) {
+ if (equal({{=$data}}[i], {{=$data}}[j])) {
+ {{=$valid}} = false;
+ break outer;
+ }
+ }
+ }
+ {{??}}
+ var itemIndices = {}, item;
+ for (;i--;) {
+ var item = {{=$data}}[i];
+ {{ var $method = 'checkDataType' + ($typeIsArray ? 's' : ''); }}
+ if ({{= it.util[$method]($itemType, 'item', true) }}) continue;
+ {{? $typeIsArray}}
+ if (typeof item == 'string') item = '"' + item;
+ {{?}}
+ if (typeof itemIndices[item] == 'number') {
{{=$valid}} = false;
- break outer;
+ j = itemIndices[item];
+ break;
}
+ itemIndices[item] = i;
}
- }
+ {{?}}
}
{{? $isData }} } {{?}}
diff --git a/node_modules/ajv/lib/dot/validate.jst b/node_modules/ajv/lib/dot/validate.jst
index 273e4c37e..27393cf30 100644
--- a/node_modules/ajv/lib/dot/validate.jst
+++ b/node_modules/ajv/lib/dot/validate.jst
@@ -21,29 +21,11 @@
}}
{{? 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
+ var validate = {{?$async}}{{it.async = true;}}async {{?}}function(data, dataPath, parentData, parentDataProperty, rootData) {
+ 'use strict';
+ {{? $id && (it.opts.sourceCode || it.opts.processCode) }}
+ {{= '/\*# sourceURL=' + $id + ' */' }}
{{?}}
- (data, dataPath, parentData, parentDataProperty, rootData) {
- 'use strict';
- {{? $id && (it.opts.sourceCode || it.opts.processCode) }}
- {{= '/\*# sourceURL=' + $id + ' */' }}
- {{?}}
{{?}}
{{? typeof it.schema == 'boolean' || !($refKeywords || it.schema.$ref) }}
@@ -70,7 +52,7 @@
{{?}}
{{? it.isTop}}
- });
+ };
return validate;
{{?}}
@@ -145,6 +127,10 @@
{{?}}
{{?}}
+{{? it.schema.$comment && it.opts.$comment }}
+ {{= it.RULES.all.$comment.code(it, '$comment') }}
+{{?}}
+
{{? $typeSchema }}
{{? it.opts.coerceTypes }}
{{ var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema); }}
@@ -176,9 +162,6 @@
{{ $closingBraces2 += '}'; }}
{{?}}
{{??}}
- {{? it.opts.v5 && it.schema.patternGroups }}
- {{ it.logger.warn('keyword "patternGroups" is deprecated and disabled. Use option patternGroups: true to enable.'); }}
- {{?}}
{{~ it.RULES:$rulesGroup }}
{{? $shouldUseGroup($rulesGroup) }}
{{? $rulesGroup.type }}
@@ -237,7 +220,7 @@
validate.errors = vErrors; {{ /* don't edit, used in replace */ }}
return errors === 0; {{ /* don't edit, used in replace */ }}
{{?}}
- });
+ };
return validate;
{{??}}