1 | {{# def.definitions }}
|
---|
2 | {{# def.errors }}
|
---|
3 | {{# def.missing }}
|
---|
4 | {{# def.setupKeyword }}
|
---|
5 | {{# def.setupNextLevel }}
|
---|
6 |
|
---|
7 |
|
---|
8 | {{## def.propertyInData:
|
---|
9 | {{=$data}}{{= it.util.getProperty($property) }} !== undefined
|
---|
10 | {{? $ownProperties }}
|
---|
11 | && Object.prototype.hasOwnProperty.call({{=$data}}, '{{=it.util.escapeQuotes($property)}}')
|
---|
12 | {{?}}
|
---|
13 | #}}
|
---|
14 |
|
---|
15 |
|
---|
16 | {{
|
---|
17 | var $schemaDeps = {}
|
---|
18 | , $propertyDeps = {}
|
---|
19 | , $ownProperties = it.opts.ownProperties;
|
---|
20 |
|
---|
21 | for ($property in $schema) {
|
---|
22 | if ($property == '__proto__') continue;
|
---|
23 | var $sch = $schema[$property];
|
---|
24 | var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
|
---|
25 | $deps[$property] = $sch;
|
---|
26 | }
|
---|
27 | }}
|
---|
28 |
|
---|
29 | var {{=$errs}} = errors;
|
---|
30 |
|
---|
31 | {{ var $currentErrorPath = it.errorPath; }}
|
---|
32 |
|
---|
33 | var missing{{=$lvl}};
|
---|
34 | {{ for (var $property in $propertyDeps) { }}
|
---|
35 | {{ $deps = $propertyDeps[$property]; }}
|
---|
36 | {{? $deps.length }}
|
---|
37 | if ({{# def.propertyInData }}
|
---|
38 | {{? $breakOnError }}
|
---|
39 | && ({{# def.checkMissingProperty:$deps }})) {
|
---|
40 | {{# def.errorMissingProperty:'dependencies' }}
|
---|
41 | {{??}}
|
---|
42 | ) {
|
---|
43 | {{~ $deps:$propertyKey }}
|
---|
44 | {{# def.allErrorsMissingProperty:'dependencies' }}
|
---|
45 | {{~}}
|
---|
46 | {{?}}
|
---|
47 | } {{# def.elseIfValid }}
|
---|
48 | {{?}}
|
---|
49 | {{ } }}
|
---|
50 |
|
---|
51 | {{
|
---|
52 | it.errorPath = $currentErrorPath;
|
---|
53 | var $currentBaseId = $it.baseId;
|
---|
54 | }}
|
---|
55 |
|
---|
56 |
|
---|
57 | {{ for (var $property in $schemaDeps) { }}
|
---|
58 | {{ var $sch = $schemaDeps[$property]; }}
|
---|
59 | {{? {{# def.nonEmptySchema:$sch }} }}
|
---|
60 | {{=$nextValid}} = true;
|
---|
61 |
|
---|
62 | if ({{# def.propertyInData }}) {
|
---|
63 | {{
|
---|
64 | $it.schema = $sch;
|
---|
65 | $it.schemaPath = $schemaPath + it.util.getProperty($property);
|
---|
66 | $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
|
---|
67 | }}
|
---|
68 |
|
---|
69 | {{# def.insertSubschemaCode }}
|
---|
70 | }
|
---|
71 |
|
---|
72 | {{# def.ifResultValid }}
|
---|
73 | {{?}}
|
---|
74 | {{ } }}
|
---|
75 |
|
---|
76 | {{? $breakOnError }}
|
---|
77 | {{= $closingBraces }}
|
---|
78 | if ({{=$errs}} == errors) {
|
---|
79 | {{?}}
|
---|