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.jst79
-rw-r--r--node_modules/ajv/lib/dot/anyOf.jst2
-rw-r--r--node_modules/ajv/lib/dot/const.jst (renamed from node_modules/ajv/lib/dot/v5/constant.jst)3
-rw-r--r--node_modules/ajv/lib/dot/contains.jst57
-rw-r--r--node_modules/ajv/lib/dot/custom.jst23
-rw-r--r--node_modules/ajv/lib/dot/definitions.def25
-rw-r--r--node_modules/ajv/lib/dot/dependencies.jst37
-rw-r--r--node_modules/ajv/lib/dot/errors.def23
-rw-r--r--node_modules/ajv/lib/dot/format.jst40
-rw-r--r--node_modules/ajv/lib/dot/items.jst1
-rw-r--r--node_modules/ajv/lib/dot/missing.def19
-rw-r--r--node_modules/ajv/lib/dot/oneOf.jst2
-rw-r--r--node_modules/ajv/lib/dot/properties.jst80
-rw-r--r--node_modules/ajv/lib/dot/propertyNames.jst54
-rw-r--r--node_modules/ajv/lib/dot/ref.jst21
-rw-r--r--node_modules/ajv/lib/dot/required.jst20
-rw-r--r--node_modules/ajv/lib/dot/v5/_formatLimit.jst116
-rw-r--r--node_modules/ajv/lib/dot/v5/patternRequired.jst28
-rw-r--r--node_modules/ajv/lib/dot/v5/switch.jst73
-rw-r--r--node_modules/ajv/lib/dot/validate.jst184
20 files changed, 482 insertions, 405 deletions
diff --git a/node_modules/ajv/lib/dot/_limit.jst b/node_modules/ajv/lib/dot/_limit.jst
index 21793d874..13e7649b3 100644
--- a/node_modules/ajv/lib/dot/_limit.jst
+++ b/node_modules/ajv/lib/dot/_limit.jst
@@ -3,47 +3,94 @@
{{# def.setupKeyword }}
{{# def.$data }}
+{{## def.setExclusiveLimit:
+ $exclusive = true;
+ $errorKeyword = $exclusiveKeyword;
+ $errSchemaPath = it.errSchemaPath + '/' + $exclusiveKeyword;
+#}}
+
{{
var $isMax = $keyword == 'maximum'
, $exclusiveKeyword = $isMax ? 'exclusiveMaximum' : 'exclusiveMinimum'
, $schemaExcl = it.schema[$exclusiveKeyword]
- , $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data
+ , $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data
, $op = $isMax ? '<' : '>'
- , $notOp = $isMax ? '>' : '<';
+ , $notOp = $isMax ? '>' : '<'
+ , $errorKeyword = undefined;
}}
{{? $isDataExcl }}
{{
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
, $exclusive = 'exclusive' + $lvl
+ , $exclType = 'exclType' + $lvl
+ , $exclIsNumber = 'exclIsNumber' + $lvl
, $opExpr = 'op' + $lvl
, $opStr = '\' + ' + $opExpr + ' + \'';
}}
var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
{{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
- var exclusive{{=$lvl}};
- if (typeof {{=$schemaValueExcl}} != 'boolean' && typeof {{=$schemaValueExcl}} != 'undefined') {
+ var {{=$exclusive}};
+ var {{=$exclType}} = typeof {{=$schemaValueExcl}};
+ if ({{=$exclType}} != 'boolean' && {{=$exclType}} != 'undefined' && {{=$exclType}} != 'number') {
{{ var $errorKeyword = $exclusiveKeyword; }}
{{# def.error:'_exclusiveLimit' }}
- } else if({{# def.$dataNotType:'number' }}
- ((exclusive{{=$lvl}} = {{=$schemaValueExcl}} === true)
- ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
- : {{=$data}} {{=$notOp}} {{=$schemaValue}})
+ } else if ({{# def.$dataNotType:'number' }}
+ {{=$exclType}} == 'number'
+ ? (
+ ({{=$exclusive}} = {{=$schemaValue}} === undefined || {{=$schemaValueExcl}} {{=$op}}= {{=$schemaValue}})
+ ? {{=$data}} {{=$notOp}}= {{=$schemaValueExcl}}
+ : {{=$data}} {{=$notOp}} {{=$schemaValue}}
+ )
+ : (
+ ({{=$exclusive}} = {{=$schemaValueExcl}} === true)
+ ? {{=$data}} {{=$notOp}}= {{=$schemaValue}}
+ : {{=$data}} {{=$notOp}} {{=$schemaValue}}
+ )
|| {{=$data}} !== {{=$data}}) {
- var op{{=$lvl}} = exclusive{{=$lvl}} ? '{{=$op}}' : '{{=$op}}=';
+ var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
{{??}}
{{
- var $exclusive = $schemaExcl === true
+ var $exclIsNumber = typeof $schemaExcl == 'number'
, $opStr = $op; /*used in error*/
- if (!$exclusive) $opStr += '=';
- var $opExpr = '\'' + $opStr + '\''; /*used in error*/
}}
- if ({{# def.$dataNotType:'number' }}
- {{=$data}} {{=$notOp}}{{?$exclusive}}={{?}} {{=$schemaValue}}
- || {{=$data}} !== {{=$data}}) {
+ {{? $exclIsNumber && $isData }}
+ {{ var $opExpr = '\'' + $opStr + '\''; /*used in error*/ }}
+ if ({{# def.$dataNotType:'number' }}
+ ( {{=$schemaValue}} === undefined
+ || {{=$schemaExcl}} {{=$op}}= {{=$schemaValue}}
+ ? {{=$data}} {{=$notOp}}= {{=$schemaExcl}}
+ : {{=$data}} {{=$notOp}} {{=$schemaValue}} )
+ || {{=$data}} !== {{=$data}}) {
+ {{??}}
+ {{
+ if ($exclIsNumber && $schema === undefined) {
+ {{# def.setExclusiveLimit }}
+ $schemaValue = $schemaExcl;
+ $notOp += '=';
+ } else {
+ if ($exclIsNumber)
+ $schemaValue = Math[$isMax ? 'min' : 'max']($schemaExcl, $schema);
+
+ if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
+ {{# def.setExclusiveLimit }}
+ $notOp += '=';
+ } else {
+ $exclusive = false;
+ $opStr += '=';
+ }
+ }
+
+ var $opExpr = '\'' + $opStr + '\''; /*used in error*/
+ }}
+
+ if ({{# def.$dataNotType:'number' }}
+ {{=$data}} {{=$notOp}} {{=$schemaValue}}
+ || {{=$data}} !== {{=$data}}) {
+ {{?}}
{{?}}
- {{ var $errorKeyword = $keyword; }}
+ {{ $errorKeyword = $errorKeyword || $keyword; }}
{{# def.error:'_limit' }}
} {{? $breakOnError }} else { {{?}}
diff --git a/node_modules/ajv/lib/dot/anyOf.jst b/node_modules/ajv/lib/dot/anyOf.jst
index 93c3cd828..086cf2b33 100644
--- a/node_modules/ajv/lib/dot/anyOf.jst
+++ b/node_modules/ajv/lib/dot/anyOf.jst
@@ -35,7 +35,7 @@
{{= $closingBraces }}
if (!{{=$valid}}) {
- {{# def.addError:'anyOf' }}
+ {{# def.extraError:'anyOf' }}
} else {
{{# def.resetErrors }}
{{? it.opts.allErrors }} } {{?}}
diff --git a/node_modules/ajv/lib/dot/v5/constant.jst b/node_modules/ajv/lib/dot/const.jst
index 67969c1b9..2aa22980d 100644
--- a/node_modules/ajv/lib/dot/v5/constant.jst
+++ b/node_modules/ajv/lib/dot/const.jst
@@ -7,4 +7,5 @@
var schema{{=$lvl}} = validate.schema{{=$schemaPath}};
{{?}}
var {{=$valid}} = equal({{=$data}}, schema{{=$lvl}});
-{{# def.checkError:'constant' }}
+{{# def.checkError:'const' }}
+{{? $breakOnError }} else { {{?}}
diff --git a/node_modules/ajv/lib/dot/contains.jst b/node_modules/ajv/lib/dot/contains.jst
new file mode 100644
index 000000000..925d2c84b
--- /dev/null
+++ b/node_modules/ajv/lib/dot/contains.jst
@@ -0,0 +1,57 @@
+{{# def.definitions }}
+{{# def.errors }}
+{{# def.setupKeyword }}
+{{# def.setupNextLevel }}
+
+
+{{
+ var $idx = 'i' + $lvl
+ , $dataNxt = $it.dataLevel = it.dataLevel + 1
+ , $nextData = 'data' + $dataNxt
+ , $currentBaseId = it.baseId
+ , $nonEmptySchema = {{# def.nonEmptySchema:$schema }};
+}}
+
+var {{=$errs}} = errors;
+var {{=$valid}};
+
+{{? $nonEmptySchema }}
+ {{# def.setCompositeRule }}
+
+ {{
+ $it.schema = $schema;
+ $it.schemaPath = $schemaPath;
+ $it.errSchemaPath = $errSchemaPath;
+ }}
+
+ var {{=$nextValid}} = false;
+
+ for (var {{=$idx}} = 0; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
+ {{
+ $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
+ var $passData = $data + '[' + $idx + ']';
+ $it.dataPathArr[$dataNxt] = $idx;
+ }}
+
+ {{# def.generateSubschemaCode }}
+ {{# def.optimizeValidate }}
+
+ if ({{=$nextValid}}) break;
+ }
+
+ {{# def.resetCompositeRule }}
+ {{= $closingBraces }}
+
+ if (!{{=$nextValid}}) {
+{{??}}
+ if ({{=$data}}.length == 0) {
+{{?}}
+
+ {{# def.error:'contains' }}
+ } else {
+ {{? $nonEmptySchema }}
+ {{# def.resetErrors }}
+ {{?}}
+ {{? it.opts.allErrors }} } {{?}}
+
+{{# def.cleanUp }}
diff --git a/node_modules/ajv/lib/dot/custom.jst b/node_modules/ajv/lib/dot/custom.jst
index e91c50e6f..402028e6b 100644
--- a/node_modules/ajv/lib/dot/custom.jst
+++ b/node_modules/ajv/lib/dot/custom.jst
@@ -6,7 +6,8 @@
{{
var $rule = this
, $definition = 'definition' + $lvl
- , $rDef = $rule.definition;
+ , $rDef = $rule.definition
+ , $closingBraces = '';
var $validate = $rDef.validate;
var $compile, $inline, $macro, $ruleValidate, $validateCode;
}}
@@ -21,6 +22,7 @@
{{??}}
{{
$ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
+ if (!$ruleValidate) return;
$schemaValue = 'validate.schema' + $schemaPath;
$validateCode = $ruleValidate.code;
$compile = $rDef.compile;
@@ -76,9 +78,16 @@ var {{=$valid}};
#}}
-{{? $validateSchema }}
- {{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
- if ({{=$valid}}) {
+{{? $isData && $rDef.$data }}
+ {{ $closingBraces += '}'; }}
+ if ({{=$schemaValue}} === undefined) {
+ {{=$valid}} = true;
+ } else {
+ {{? $validateSchema }}
+ {{ $closingBraces += '}'; }}
+ {{=$valid}} = {{=$definition}}.validateSchema({{=$schemaValue}});
+ if ({{=$valid}}) {
+ {{?}}
{{?}}
{{? $inline }}
@@ -123,12 +132,10 @@ var {{=$valid}};
{{?}}
{{? $rDef.modifying }}
- {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
+ if ({{=$parentData}}) {{=$data}} = {{=$parentData}}[{{=$parentDataProperty}}];
{{?}}
-{{? $validateSchema }}
- }
-{{?}}
+{{= $closingBraces }}
{{## def.notValidationResult:
{{? $rDef.valid === undefined }}
diff --git a/node_modules/ajv/lib/dot/definitions.def b/node_modules/ajv/lib/dot/definitions.def
index a442346f5..cdbe140bb 100644
--- a/node_modules/ajv/lib/dot/definitions.def
+++ b/node_modules/ajv/lib/dot/definitions.def
@@ -113,12 +113,12 @@
{{## def.cleanUp: {{ out = it.util.cleanUpCode(out); }} #}}
-{{## def.cleanUpVarErrors: {{ out = it.util.cleanUpVarErrors(out, $async); }} #}}
+{{## def.finalCleanUp: {{ out = it.util.finalCleanUpCode(out, $async); }} #}}
{{## def.$data:
{{
- var $isData = it.opts.v5 && $schema && $schema.$data
+ var $isData = it.opts.$data && $schema && $schema.$data
, $schemaValue;
}}
{{? $isData }}
@@ -175,8 +175,25 @@
#}}
-{{## def.checkOwnProperty:
+{{## def.iterateProperties:
{{? $ownProperties }}
- if (!Object.prototype.hasOwnProperty.call({{=$data}}, {{=$key}})) continue;
+ {{=$dataProperties}} = {{=$dataProperties}} || Object.keys({{=$data}});
+ for (var {{=$idx}}=0; {{=$idx}}<{{=$dataProperties}}.length; {{=$idx}}++) {
+ var {{=$key}} = {{=$dataProperties}}[{{=$idx}}];
+ {{??}}
+ for (var {{=$key}} in {{=$data}}) {
{{?}}
#}}
+
+
+{{## def.noPropertyInData:
+ {{=$useData}} === undefined
+ {{? $ownProperties }}
+ || !{{# def.isOwnProperty }}
+ {{?}}
+#}}
+
+
+{{## def.isOwnProperty:
+ Object.prototype.hasOwnProperty.call({{=$data}}, '{{=it.util.escapeQuotes($propertyKey)}}')
+#}}
diff --git a/node_modules/ajv/lib/dot/dependencies.jst b/node_modules/ajv/lib/dot/dependencies.jst
index 1198a45fe..c41f33422 100644
--- a/node_modules/ajv/lib/dot/dependencies.jst
+++ b/node_modules/ajv/lib/dot/dependencies.jst
@@ -5,9 +5,18 @@
{{# def.setupNextLevel }}
+{{## def.propertyInData:
+ {{=$data}}{{= it.util.getProperty($property) }} !== undefined
+ {{? $ownProperties }}
+ && Object.prototype.hasOwnProperty.call({{=$data}}, '{{=it.util.escapeQuotes($property)}}')
+ {{?}}
+#}}
+
+
{{
var $schemaDeps = {}
- , $propertyDeps = {};
+ , $propertyDeps = {}
+ , $ownProperties = it.opts.ownProperties;
for ($property in $schema) {
var $sch = $schema[$property];
@@ -23,17 +32,19 @@ var {{=$errs}} = errors;
var missing{{=$lvl}};
{{ for (var $property in $propertyDeps) { }}
{{ $deps = $propertyDeps[$property]; }}
- if ({{=$data}}{{= it.util.getProperty($property) }} !== undefined
- {{? $breakOnError }}
- && ({{# def.checkMissingProperty:$deps }})) {
- {{# def.errorMissingProperty:'dependencies' }}
- {{??}}
- ) {
- {{~ $deps:$reqProperty }}
- {{# def.allErrorsMissingProperty:'dependencies' }}
- {{~}}
- {{?}}
- } {{# def.elseIfValid }}
+ {{? $deps.length }}
+ if ({{# def.propertyInData }}
+ {{? $breakOnError }}
+ && ({{# def.checkMissingProperty:$deps }})) {
+ {{# def.errorMissingProperty:'dependencies' }}
+ {{??}}
+ ) {
+ {{~ $deps:$propertyKey }}
+ {{# def.allErrorsMissingProperty:'dependencies' }}
+ {{~}}
+ {{?}}
+ } {{# def.elseIfValid }}
+ {{?}}
{{ } }}
{{
@@ -47,7 +58,7 @@ var missing{{=$lvl}};
{{? {{# def.nonEmptySchema:$sch }} }}
{{=$nextValid}} = true;
- if ({{=$data}}{{= it.util.getProperty($property) }} !== undefined) {
+ if ({{# def.propertyInData }}) {
{{
$it.schema = $sch;
$it.schemaPath = $schemaPath + it.util.getProperty($property);
diff --git a/node_modules/ajv/lib/dot/errors.def b/node_modules/ajv/lib/dot/errors.def
index 3e0472120..b79646fc2 100644
--- a/node_modules/ajv/lib/dot/errors.def
+++ b/node_modules/ajv/lib/dot/errors.def
@@ -87,14 +87,17 @@
{{## def.concatSchema:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=$schema}}{{?}}#}}
-{{## def.appendSchema:{{?$isData}}' + {{=$schemaValue}}{{??}}{{=$schema}}'{{?}}#}}
+{{## def.appendSchema:{{?$isData}}' + {{=$schemaValue}}{{??}}{{=$schemaValue}}'{{?}}#}}
{{## def.concatSchemaEQ:{{?$isData}}' + {{=$schemaValue}} + '{{??}}{{=it.util.escapeQuotes($schema)}}{{?}}#}}
{{## def._errorMessages = {
+ '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'",
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}}\"'",
@@ -107,14 +110,14 @@
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}}{{?}}'",
uniqueItems: "'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)'",
custom: "'should pass \"{{=$rule.keyword}}\" keyword validation'",
- patternGroups: "'should NOT have {{=$moreOrLess}} than {{=$limit}} properties matching pattern \"{{=it.util.escapeQuotes($pgProperty)}}\"'",
patternRequired: "'should have property matching pattern \\'{{=$missingPattern}}\\''",
switch: "'should pass \"switch\" keyword validation'",
- constant: "'should be equal to constant'",
_formatLimit: "'should be {{=$opStr}} \"{{#def.concatSchemaEQ}}\"'",
_formatExclusiveLimit: "'{{=$exclusiveKeyword}} should be boolean'"
} #}}
@@ -124,10 +127,13 @@
{{## def.schemaRefOrQS: {{?$isData}}validate.schema{{=$schemaPath}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
{{## def._errorSchemas = {
+ 'false schema': "false",
$ref: "{{=it.util.toQuotedString($schema)}}",
additionalItems: "false",
additionalProperties: "false",
anyOf: "validate.schema{{=$schemaPath}}",
+ const: "validate.schema{{=$schemaPath}}",
+ contains: "validate.schema{{=$schemaPath}}",
dependencies: "validate.schema{{=$schemaPath}}",
'enum': "validate.schema{{=$schemaPath}}",
format: "{{#def.schemaRefOrQS}}",
@@ -140,14 +146,14 @@
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}}",
uniqueItems: "{{#def.schemaRefOrVal}}",
custom: "validate.schema{{=$schemaPath}}",
- patternGroups: "validate.schema{{=$schemaPath}}",
patternRequired: "validate.schema{{=$schemaPath}}",
switch: "validate.schema{{=$schemaPath}}",
- constant: "validate.schema{{=$schemaPath}}",
_formatLimit: "{{#def.schemaRefOrQS}}",
_formatExclusiveLimit: "validate.schema{{=$schemaPath}}"
} #}}
@@ -156,10 +162,13 @@
{{## def.schemaValueQS: {{?$isData}}{{=$schemaValue}}{{??}}{{=it.util.toQuotedString($schema)}}{{?}} #}}
{{## def._errorParams = {
+ 'false schema': "{}",
$ref: "{ ref: '{{=it.util.escapeQuotes($schema)}}' }",
additionalItems: "{ limit: {{=$schema.length}} }",
additionalProperties: "{ additionalProperty: '{{=$additionalProperty}}' }",
anyOf: "{}",
+ const: "{}",
+ 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}} }",
@@ -172,14 +181,14 @@
not: "{}",
oneOf: "{}",
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}}{{?}}' }",
uniqueItems: "{ i: i, j: j }",
custom: "{ keyword: '{{=$rule.keyword}}' }",
- patternGroups: "{ reason: '{{=$reason}}', limit: {{=$limit}}, pattern: '{{=it.util.escapeQuotes($pgProperty)}}' }",
patternRequired: "{ missingPattern: '{{=$missingPattern}}' }",
switch: "{ caseIndex: {{=$caseIndex}} }",
- constant: "{}",
_formatLimit: "{ comparison: {{=$opExpr}}, limit: {{#def.schemaValueQS}}, exclusive: {{=$exclusive}} }",
_formatExclusiveLimit: "{}"
} #}}
diff --git a/node_modules/ajv/lib/dot/format.jst b/node_modules/ajv/lib/dot/format.jst
index 961fe4fc9..074d16c31 100644
--- a/node_modules/ajv/lib/dot/format.jst
+++ b/node_modules/ajv/lib/dot/format.jst
@@ -15,13 +15,14 @@
{{## def.$dataCheckFormat:
{{# def.$dataNotType:'string' }}
- ({{? $unknownFormats === true || $allowUnknown }}
+ ({{? $unknownFormats != 'ignore' }}
({{=$schemaValue}} && !{{=$format}}
{{? $allowUnknown }}
&& self._opts.unknownFormats.indexOf({{=$schemaValue}}) == -1
{{?}}) ||
{{?}}
- ({{=$format}} && !(typeof {{=$format}} == 'function'
+ ({{=$format}} && {{=$formatType}} == '{{=$ruleType}}'
+ && !(typeof {{=$format}} == 'function'
? {{? it.async}}
(async{{=$lvl}} ? {{=it.yieldAwait}} {{=$format}}({{=$data}}) : {{=$format}}({{=$data}}))
{{??}}
@@ -49,12 +50,17 @@
}}
{{? $isData }}
- {{ var $format = 'format' + $lvl; }}
+ {{
+ var $format = 'format' + $lvl
+ , $isObject = 'isObject' + $lvl
+ , $formatType = 'formatType' + $lvl;
+ }}
var {{=$format}} = formats[{{=$schemaValue}}];
- var isObject{{=$lvl}} = typeof {{=$format}} == 'object'
- && !({{=$format}} instanceof RegExp)
- && {{=$format}}.validate;
- if (isObject{{=$lvl}}) {
+ var {{=$isObject}} = typeof {{=$format}} == 'object'
+ && !({{=$format}} instanceof RegExp)
+ && {{=$format}}.validate;
+ var {{=$formatType}} = {{=$isObject}} && {{=$format}}.type || 'string';
+ if ({{=$isObject}}) {
{{? it.async}}
var async{{=$lvl}} = {{=$format}}.async;
{{?}}
@@ -64,28 +70,28 @@
{{??}}
{{ var $format = it.formats[$schema]; }}
{{? !$format }}
- {{? $unknownFormats === true || ($allowUnknown && $unknownFormats.indexOf($schema) == -1) }}
- {{ throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"'); }}
- {{??}}
- {{
- if (!$allowUnknown) {
- console.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
- if ($unknownFormats !== 'ignore')
- console.warn('In the next major version it will throw exception. See option unknownFormats for more information');
- }
- }}
+ {{? $unknownFormats == 'ignore' }}
+ {{ console.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"'); }}
{{# def.skipFormat }}
+ {{?? $allowUnknown && $unknownFormats.indexOf($schema) >= 0 }}
+ {{# def.skipFormat }}
+ {{??}}
+ {{ throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"'); }}
{{?}}
{{?}}
{{
var $isObject = typeof $format == 'object'
&& !($format instanceof RegExp)
&& $format.validate;
+ var $formatType = $isObject && $format.type || 'string';
if ($isObject) {
var $async = $format.async === true;
$format = $format.validate;
}
}}
+ {{? $formatType != $ruleType }}
+ {{# def.skipFormat }}
+ {{?}}
{{? $async }}
{{
if (!it.async) throw new Error('async format in sync schema');
diff --git a/node_modules/ajv/lib/dot/items.jst b/node_modules/ajv/lib/dot/items.jst
index a8b8aa7dd..8c0f5acb5 100644
--- a/node_modules/ajv/lib/dot/items.jst
+++ b/node_modules/ajv/lib/dot/items.jst
@@ -90,7 +90,6 @@ var {{=$valid}};
$it.errSchemaPath = $errSchemaPath;
}}
{{# def.validateItems: 0 }}
- {{# def.ifResultValid }}
{{?}}
{{? $breakOnError }}
diff --git a/node_modules/ajv/lib/dot/missing.def b/node_modules/ajv/lib/dot/missing.def
index 23ad04cf4..a73b9f966 100644
--- a/node_modules/ajv/lib/dot/missing.def
+++ b/node_modules/ajv/lib/dot/missing.def
@@ -1,8 +1,11 @@
{{## def.checkMissingProperty:_properties:
- {{~ _properties:_$property:$i }}
+ {{~ _properties:$propertyKey:$i }}
{{?$i}} || {{?}}
- {{ var $prop = it.util.getProperty(_$property); }}
- ( {{=$data}}{{=$prop}} === undefined && (missing{{=$lvl}} = {{= it.util.toQuotedString(it.opts.jsonPointers ? _$property : $prop) }}) )
+ {{
+ var $prop = it.util.getProperty($propertyKey)
+ , $useData = $data + $prop;
+ }}
+ ( ({{# def.noPropertyInData }}) && (missing{{=$lvl}} = {{= it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) }}) )
{{~}}
#}}
@@ -20,15 +23,17 @@
{{# def.error:_error }}
#}}
+
{{## def.allErrorsMissingProperty:_error:
{{
- var $prop = it.util.getProperty($reqProperty)
- , $missingProperty = it.util.escapeQuotes($reqProperty);
+ var $prop = it.util.getProperty($propertyKey)
+ , $missingProperty = it.util.escapeQuotes($propertyKey)
+ , $useData = $data + $prop;
if (it.opts._errorDataPathProperty) {
- it.errorPath = it.util.getPath($currentErrorPath, $reqProperty, it.opts.jsonPointers);
+ it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
}
}}
- if ({{=$data}}{{=$prop}} === undefined) {
+ if ({{# def.noPropertyInData }}) {
{{# def.addError:_error }}
}
#}}
diff --git a/node_modules/ajv/lib/dot/oneOf.jst b/node_modules/ajv/lib/dot/oneOf.jst
index b7f7bff07..59a435549 100644
--- a/node_modules/ajv/lib/dot/oneOf.jst
+++ b/node_modules/ajv/lib/dot/oneOf.jst
@@ -38,7 +38,7 @@ var {{=$valid}} = false;
{{= $closingBraces }}
if (!{{=$valid}}) {
- {{# def.error:'oneOf' }}
+ {{# def.extraError:'oneOf' }}
} else {
{{# def.resetErrors }}
{{? it.opts.allErrors }} } {{?}}
diff --git a/node_modules/ajv/lib/dot/properties.jst b/node_modules/ajv/lib/dot/properties.jst
index 3a4b966ff..8d56324b7 100644
--- a/node_modules/ajv/lib/dot/properties.jst
+++ b/node_modules/ajv/lib/dot/properties.jst
@@ -23,8 +23,10 @@
{{
var $key = 'key' + $lvl
+ , $idx = 'idx' + $lvl
, $dataNxt = $it.dataLevel = it.dataLevel + 1
- , $nextData = 'data' + $dataNxt;
+ , $nextData = 'data' + $dataNxt
+ , $dataProperties = 'dataProperties' + $lvl;
var $schemaKeys = Object.keys($schema || {})
, $pProperties = it.schema.patternProperties || {}
@@ -43,7 +45,7 @@
if ($required && !(it.opts.v5 && $required.$data) && $required.length < it.opts.loopRequired)
var $requiredHash = it.util.toHash($required);
- if (it.opts.v5) {
+ if (it.opts.patternGroups) {
var $pgProperties = it.schema.patternGroups || {}
, $pgPropertyKeys = Object.keys($pgProperties);
}
@@ -52,10 +54,12 @@
var {{=$errs}} = errors;
var {{=$nextValid}} = true;
+{{? $ownProperties }}
+ var {{=$dataProperties}} = undefined;
+{{?}}
{{? $checkAdditional }}
- for (var {{=$key}} in {{=$data}}) {
- {{# def.checkOwnProperty }}
+ {{# def.iterateProperties }}
{{? $someProperties }}
var isAdditional{{=$lvl}} = !(false
{{? $schemaKeys.length }}
@@ -72,7 +76,7 @@ var {{=$nextValid}} = true;
|| {{= it.usePattern($pProperty) }}.test({{=$key}})
{{~}}
{{?}}
- {{? it.opts.v5 && $pgPropertyKeys && $pgPropertyKeys.length }}
+ {{? it.opts.patternGroups && $pgPropertyKeys.length }}
{{~ $pgPropertyKeys:$pgProperty:$i }}
|| {{= it.usePattern($pgProperty) }}.test({{=$key}})
{{~}}
@@ -170,7 +174,7 @@ var {{=$nextValid}} = true;
{{= $code }}
{{??}}
{{? $requiredHash && $requiredHash[$propertyKey] }}
- if ({{=$useData}} === undefined) {
+ if ({{# def.noPropertyInData }}) {
{{=$nextValid}} = false;
{{
var $currentErrorPath = it.errorPath
@@ -187,11 +191,15 @@ var {{=$nextValid}} = true;
} else {
{{??}}
{{? $breakOnError }}
- if ({{=$useData}} === undefined) {
+ if ({{# def.noPropertyInData }}) {
{{=$nextValid}} = true;
} else {
{{??}}
- if ({{=$useData}} !== undefined) {
+ if ({{=$useData}} !== undefined
+ {{? $ownProperties }}
+ && {{# def.isOwnProperty }}
+ {{?}}
+ ) {
{{?}}
{{?}}
@@ -204,40 +212,41 @@ var {{=$nextValid}} = true;
{{~}}
{{?}}
-{{~ $pPropertyKeys:$pProperty }}
- {{ var $sch = $pProperties[$pProperty]; }}
+{{? $pPropertyKeys.length }}
+ {{~ $pPropertyKeys:$pProperty }}
+ {{ var $sch = $pProperties[$pProperty]; }}
- {{? {{# def.nonEmptySchema:$sch}} }}
- {{
- $it.schema = $sch;
- $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
- $it.errSchemaPath = it.errSchemaPath + '/patternProperties/'
- + it.util.escapeFragment($pProperty);
- }}
+ {{? {{# def.nonEmptySchema:$sch}} }}
+ {{
+ $it.schema = $sch;
+ $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
+ $it.errSchemaPath = it.errSchemaPath + '/patternProperties/'
+ + it.util.escapeFragment($pProperty);
+ }}
- for (var {{=$key}} in {{=$data}}) {
- {{# def.checkOwnProperty }}
- if ({{= it.usePattern($pProperty) }}.test({{=$key}})) {
- {{
- $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
- var $passData = $data + '[' + $key + ']';
- $it.dataPathArr[$dataNxt] = $key;
- }}
+ {{# def.iterateProperties }}
+ if ({{= it.usePattern($pProperty) }}.test({{=$key}})) {
+ {{
+ $it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
+ var $passData = $data + '[' + $key + ']';
+ $it.dataPathArr[$dataNxt] = $key;
+ }}
- {{# def.generateSubschemaCode }}
- {{# def.optimizeValidate }}
+ {{# def.generateSubschemaCode }}
+ {{# def.optimizeValidate }}
- {{? $breakOnError }} if (!{{=$nextValid}}) break; {{?}}
+ {{? $breakOnError }} if (!{{=$nextValid}}) break; {{?}}
+ }
+ {{? $breakOnError }} else {{=$nextValid}} = true; {{?}}
}
- {{? $breakOnError }} else {{=$nextValid}} = true; {{?}}
- }
- {{# def.ifResultValid }}
- {{?}} {{ /* def.nonEmptySchema */ }}
-{{~}}
+ {{# def.ifResultValid }}
+ {{?}} {{ /* def.nonEmptySchema */ }}
+ {{~}}
+{{?}}
-{{? it.opts.v5 }}
+{{? it.opts.patternGroups && $pgPropertyKeys.length }}
{{~ $pgPropertyKeys:$pgProperty }}
{{
var $pgSchema = $pgProperties[$pgProperty]
@@ -255,8 +264,7 @@ var {{=$nextValid}} = true;
var pgPropCount{{=$lvl}} = 0;
- for (var {{=$key}} in {{=$data}}) {
- {{# def.checkOwnProperty }}
+ {{# def.iterateProperties }}
if ({{= it.usePattern($pgProperty) }}.test({{=$key}})) {
pgPropCount{{=$lvl}}++;
diff --git a/node_modules/ajv/lib/dot/propertyNames.jst b/node_modules/ajv/lib/dot/propertyNames.jst
new file mode 100644
index 000000000..51caffc20
--- /dev/null
+++ b/node_modules/ajv/lib/dot/propertyNames.jst
@@ -0,0 +1,54 @@
+{{# def.definitions }}
+{{# def.errors }}
+{{# def.setupKeyword }}
+{{# def.setupNextLevel }}
+
+{{? {{# def.nonEmptySchema:$schema }} }}
+ {{
+ $it.schema = $schema;
+ $it.schemaPath = $schemaPath;
+ $it.errSchemaPath = $errSchemaPath;
+ }}
+
+ {{
+ var $key = 'key' + $lvl
+ , $idx = 'idx' + $lvl
+ , $i = 'i' + $lvl
+ , $invalidName = '\' + ' + $key + ' + \''
+ , $dataNxt = $it.dataLevel = it.dataLevel + 1
+ , $nextData = 'data' + $dataNxt
+ , $dataProperties = 'dataProperties' + $lvl
+ , $ownProperties = it.opts.ownProperties
+ , $currentBaseId = it.baseId;
+ }}
+
+ var {{=$errs}} = errors;
+
+ {{? $ownProperties }}
+ var {{=$dataProperties}} = undefined;
+ {{?}}
+ {{# def.iterateProperties }}
+ var startErrs{{=$lvl}} = errors;
+
+ {{ var $passData = $key; }}
+ {{# def.setCompositeRule }}
+ {{# def.generateSubschemaCode }}
+ {{# def.optimizeValidate }}
+ {{# def.resetCompositeRule }}
+
+ if (!{{=$nextValid}}) {
+ for (var {{=$i}}=startErrs{{=$lvl}}; {{=$i}}<errors; {{=$i}}++) {
+ vErrors[{{=$i}}].propertyName = {{=$key}};
+ }
+ {{# def.extraError:'propertyNames' }}
+ {{? $breakOnError }} break; {{?}}
+ }
+ }
+{{?}}
+
+{{? $breakOnError }}
+ {{= $closingBraces }}
+ if ({{=$errs}} == errors) {
+{{?}}
+
+{{# def.cleanUp }}
diff --git a/node_modules/ajv/lib/dot/ref.jst b/node_modules/ajv/lib/dot/ref.jst
index e8cdc4435..4a0889686 100644
--- a/node_modules/ajv/lib/dot/ref.jst
+++ b/node_modules/ajv/lib/dot/ref.jst
@@ -25,21 +25,16 @@
{{??}}
{{ var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); }}
{{? $refVal === undefined }}
- {{ var $message = 'can\'t resolve reference ' + $schema + ' from id ' + it.baseId; }}
+ {{ var $message = it.MissingRefError.message(it.baseId, $schema); }}
{{? it.opts.missingRefs == 'fail' }}
- {{ console.log($message); }}
+ {{ console.error($message); }}
{{# def.error:'$ref' }}
{{? $breakOnError }} if (false) { {{?}}
{{?? it.opts.missingRefs == 'ignore' }}
- {{ console.log($message); }}
+ {{ console.warn($message); }}
{{? $breakOnError }} if (true) { {{?}}
{{??}}
- {{
- var $error = new Error($message);
- $error.missingRef = it.resolve.url(it.baseId, $schema);
- $error.missingSchema = it.resolve.normalizeId(it.resolve.fullPath($error.missingRef));
- throw $error;
- }}
+ {{ throw new it.MissingRefError(it.baseId, $schema, $message); }}
{{?}}
{{?? $refVal.inline }}
{{# def.setupNextLevel }}
@@ -68,12 +63,16 @@
{{? $async }}
{{ if (!it.async) throw new Error('async schema referenced by sync schema'); }}
- try { {{? $breakOnError }}var {{=$valid}} ={{?}} {{=it.yieldAwait}} {{=__callValidate}}; }
- catch (e) {
+ {{? $breakOnError }} var {{=$valid}}; {{?}}
+ try {
+ {{=it.yieldAwait}} {{=__callValidate}};
+ {{? $breakOnError }} {{=$valid}} = true; {{?}}
+ } catch (e) {
if (!(e instanceof ValidationError)) throw e;
if (vErrors === null) vErrors = e.errors;
else vErrors = vErrors.concat(e.errors);
errors = vErrors.length;
+ {{? $breakOnError }} {{=$valid}} = false; {{?}}
}
{{? $breakOnError }} if ({{=$valid}}) { {{?}}
{{??}}
diff --git a/node_modules/ajv/lib/dot/required.jst b/node_modules/ajv/lib/dot/required.jst
index e109568f3..80fde35e8 100644
--- a/node_modules/ajv/lib/dot/required.jst
+++ b/node_modules/ajv/lib/dot/required.jst
@@ -22,6 +22,11 @@
#}}
+{{## def.isRequiredOwnProperty:
+ Object.prototype.hasOwnProperty.call({{=$data}}, {{=$vSchema}}[{{=$i}}])
+#}}
+
+
{{? !$isData }}
{{? $schema.length < it.opts.loopRequired &&
it.schema.properties && Object.keys(it.schema.properties).length }}
@@ -41,7 +46,8 @@
{{? $isData || $required.length }}
{{
var $currentErrorPath = it.errorPath
- , $loopRequired = $isData || $required.length >= it.opts.loopRequired;
+ , $loopRequired = $isData || $required.length >= it.opts.loopRequired
+ , $ownProperties = it.opts.ownProperties;
}}
{{? $breakOnError }}
@@ -53,7 +59,10 @@
{{?$isData}}{{# def.check$dataIsArray }}{{?}}
for (var {{=$i}} = 0; {{=$i}} < {{=$vSchema}}.length; {{=$i}}++) {
- {{=$valid}} = {{=$data}}[{{=$vSchema}}[{{=$i}}]] !== undefined;
+ {{=$valid}} = {{=$data}}[{{=$vSchema}}[{{=$i}}]] !== undefined
+ {{? $ownProperties }}
+ && {{# def.isRequiredOwnProperty }}
+ {{?}};
if (!{{=$valid}}) break;
}
@@ -76,14 +85,17 @@
{{?}}
for (var {{=$i}} = 0; {{=$i}} < {{=$vSchema}}.length; {{=$i}}++) {
- if ({{=$data}}[{{=$vSchema}}[{{=$i}}]] === undefined) {
+ if ({{=$data}}[{{=$vSchema}}[{{=$i}}]] === undefined
+ {{? $ownProperties }}
+ || !{{# def.isRequiredOwnProperty }}
+ {{?}}) {
{{# def.addError:'required' }}
}
}
{{? $isData }} } {{?}}
{{??}}
- {{~ $required:$reqProperty }}
+ {{~ $required:$propertyKey }}
{{# def.allErrorsMissingProperty:'required' }}
{{~}}
{{?}}
diff --git a/node_modules/ajv/lib/dot/v5/_formatLimit.jst b/node_modules/ajv/lib/dot/v5/_formatLimit.jst
deleted file mode 100644
index af16b88d8..000000000
--- a/node_modules/ajv/lib/dot/v5/_formatLimit.jst
+++ /dev/null
@@ -1,116 +0,0 @@
-{{# def.definitions }}
-{{# def.errors }}
-{{# def.setupKeyword }}
-
-var {{=$valid}} = undefined;
-
-{{## def.skipFormatLimit:
- {{=$valid}} = true;
- {{ return out; }}
-#}}
-
-{{## def.compareFormat:
- {{? $isData }}
- if ({{=$schemaValue}} === undefined) {{=$valid}} = true;
- else if (typeof {{=$schemaValue}} != 'string') {{=$valid}} = false;
- else {
- {{ $closingBraces += '}'; }}
- {{?}}
-
- {{? $isDataFormat }}
- if (!{{=$compare}}) {{=$valid}} = true;
- else {
- {{ $closingBraces += '}'; }}
- {{?}}
-
- var {{=$result}} = {{=$compare}}({{=$data}}, {{# def.schemaValueQS }});
-
- if ({{=$result}} === undefined) {{=$valid}} = false;
-#}}
-
-
-{{? it.opts.format === false }}{{# def.skipFormatLimit }}{{?}}
-
-{{
- var $schemaFormat = it.schema.format
- , $isDataFormat = it.opts.v5 && $schemaFormat.$data
- , $closingBraces = '';
-}}
-
-{{? $isDataFormat }}
- {{
- var $schemaValueFormat = it.util.getData($schemaFormat.$data, $dataLvl, it.dataPathArr)
- , $format = 'format' + $lvl
- , $compare = 'compare' + $lvl;
- }}
-
- var {{=$format}} = formats[{{=$schemaValueFormat}}]
- , {{=$compare}} = {{=$format}} && {{=$format}}.compare;
-{{??}}
- {{ var $format = it.formats[$schemaFormat]; }}
- {{? !($format && $format.compare) }}
- {{# def.skipFormatLimit }}
- {{?}}
- {{ var $compare = 'formats' + it.util.getProperty($schemaFormat) + '.compare'; }}
-{{?}}
-
-{{
- var $isMax = $keyword == 'formatMaximum'
- , $exclusiveKeyword = 'formatExclusive' + ($isMax ? 'Maximum' : 'Minimum')
- , $schemaExcl = it.schema[$exclusiveKeyword]
- , $isDataExcl = it.opts.v5 && $schemaExcl && $schemaExcl.$data
- , $op = $isMax ? '<' : '>'
- , $result = 'result' + $lvl;
-}}
-
-{{# def.$data }}
-
-
-{{? $isDataExcl }}
- {{
- var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr)
- , $exclusive = 'exclusive' + $lvl
- , $opExpr = 'op' + $lvl
- , $opStr = '\' + ' + $opExpr + ' + \'';
- }}
- var schemaExcl{{=$lvl}} = {{=$schemaValueExcl}};
- {{ $schemaValueExcl = 'schemaExcl' + $lvl; }}
-
- if (typeof {{=$schemaValueExcl}} != 'boolean' && {{=$schemaValueExcl}} !== undefined) {
- {{=$valid}} = false;
- {{ var $errorKeyword = $exclusiveKeyword; }}
- {{# def.error:'_formatExclusiveLimit' }}
- }
-
- {{# def.elseIfValid }}
-
- {{# def.compareFormat }}
- var {{=$exclusive}} = {{=$schemaValueExcl}} === true;
-
- if ({{=$valid}} === undefined) {
- {{=$valid}} = {{=$exclusive}}
- ? {{=$result}} {{=$op}} 0
- : {{=$result}} {{=$op}}= 0;
- }
-
- if (!{{=$valid}}) var op{{=$lvl}} = {{=$exclusive}} ? '{{=$op}}' : '{{=$op}}=';
-{{??}}
- {{
- var $exclusive = $schemaExcl === true
- , $opStr = $op; /*used in error*/
- if (!$exclusive) $opStr += '=';
- var $opExpr = '\'' + $opStr + '\''; /*used in error*/
- }}
-
- {{# def.compareFormat }}
-
- if ({{=$valid}} === undefined)
- {{=$valid}} = {{=$result}} {{=$op}}{{?!$exclusive}}={{?}} 0;
-{{?}}
-
-{{= $closingBraces }}
-
-if (!{{=$valid}}) {
- {{ var $errorKeyword = $keyword; }}
- {{# def.error:'_formatLimit' }}
-}
diff --git a/node_modules/ajv/lib/dot/v5/patternRequired.jst b/node_modules/ajv/lib/dot/v5/patternRequired.jst
deleted file mode 100644
index 9af2cdc9d..000000000
--- a/node_modules/ajv/lib/dot/v5/patternRequired.jst
+++ /dev/null
@@ -1,28 +0,0 @@
-{{# def.definitions }}
-{{# def.errors }}
-{{# def.setupKeyword }}
-
-{{
- var $key = 'key' + $lvl
- , $matched = 'patternMatched' + $lvl
- , $closingBraces = ''
- , $ownProperties = it.opts.ownProperties;
-}}
-
-var {{=$valid}} = true;
-{{~ $schema:$pProperty }}
- var {{=$matched}} = false;
- for (var {{=$key}} in {{=$data}}) {
- {{# def.checkOwnProperty }}
- {{=$matched}} = {{= it.usePattern($pProperty) }}.test({{=$key}});
- if ({{=$matched}}) break;
- }
-
- {{ var $missingPattern = it.util.escapeQuotes($pProperty); }}
- if (!{{=$matched}}) {
- {{=$valid}} = false;
- {{# def.addError:'patternRequired' }}
- } {{# def.elseIfValid }}
-{{~}}
-
-{{= $closingBraces }}
diff --git a/node_modules/ajv/lib/dot/v5/switch.jst b/node_modules/ajv/lib/dot/v5/switch.jst
deleted file mode 100644
index 389678e34..000000000
--- a/node_modules/ajv/lib/dot/v5/switch.jst
+++ /dev/null
@@ -1,73 +0,0 @@
-{{# def.definitions }}
-{{# def.errors }}
-{{# def.setupKeyword }}
-{{# def.setupNextLevel }}
-
-
-{{## def.validateIf:
- {{# def.setCompositeRule }}
- {{ $it.createErrors = false; }}
- {{# def._validateSwitchRule:if }}
- {{ $it.createErrors = true; }}
- {{# def.resetCompositeRule }}
- {{=$ifPassed}} = {{=$nextValid}};
-#}}
-
-{{## def.validateThen:
- {{? typeof $sch.then == 'boolean' }}
- {{? $sch.then === false }}
- {{# def.error:'switch' }}
- {{?}}
- var {{=$nextValid}} = {{= $sch.then }};
- {{??}}
- {{# def._validateSwitchRule:then }}
- {{?}}
-#}}
-
-{{## def._validateSwitchRule:_clause:
- {{
- $it.schema = $sch._clause;
- $it.schemaPath = $schemaPath + '[' + $caseIndex + ']._clause';
- $it.errSchemaPath = $errSchemaPath + '/' + $caseIndex + '/_clause';
- }}
- {{# def.insertSubschemaCode }}
-#}}
-
-{{## def.switchCase:
- {{? $sch.if && {{# def.nonEmptySchema:$sch.if }} }}
- var {{=$errs}} = errors;
- {{# def.validateIf }}
- if ({{=$ifPassed}}) {
- {{# def.validateThen }}
- } else {
- {{# def.resetErrors }}
- }
- {{??}}
- {{=$ifPassed}} = true;
- {{# def.validateThen }}
- {{?}}
-#}}
-
-
-{{
- var $ifPassed = 'ifPassed' + it.level
- , $currentBaseId = $it.baseId
- , $shouldContinue;
-}}
-var {{=$ifPassed}};
-
-{{~ $schema:$sch:$caseIndex }}
- {{? $caseIndex && !$shouldContinue }}
- if (!{{=$ifPassed}}) {
- {{ $closingBraces+= '}'; }}
- {{?}}
-
- {{# def.switchCase }}
- {{ $shouldContinue = $sch.continue }}
-{{~}}
-
-{{= $closingBraces }}
-
-var {{=$valid}} = {{=$nextValid}};
-
-{{# def.cleanUp }}
diff --git a/node_modules/ajv/lib/dot/validate.jst b/node_modules/ajv/lib/dot/validate.jst
index 896e0860a..4ebc599c0 100644
--- a/node_modules/ajv/lib/dot/validate.jst
+++ b/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;
}
}}