aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ajv/lib/dot/dependencies.jst
blob: 1198a45fe0bd8e291dbedef478abfc93a73b9033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{{# def.definitions }}
{{# def.errors }}
{{# def.missing }}
{{# def.setupKeyword }}
{{# def.setupNextLevel }}


{{
  var $schemaDeps = {}
    , $propertyDeps = {};

  for ($property in $schema) {
    var $sch = $schema[$property];
    var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
    $deps[$property] = $sch;
  }
}}

var {{=$errs}} = errors;

{{ var $currentErrorPath = it.errorPath; }}

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 }}
{{ } }}

{{
  it.errorPath = $currentErrorPath;
  var $currentBaseId = $it.baseId;
}}


{{ for (var $property in $schemaDeps) { }}
  {{ var $sch = $schemaDeps[$property]; }}
  {{? {{# def.nonEmptySchema:$sch }} }}
    {{=$nextValid}} = true;

    if ({{=$data}}{{= it.util.getProperty($property) }} !== undefined) {
      {{ 
        $it.schema = $sch;
        $it.schemaPath = $schemaPath + it.util.getProperty($property);
        $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property);
      }}

      {{# def.insertSubschemaCode }}
    }

    {{# def.ifResultValid }}
  {{?}}
{{ } }}

{{? $breakOnError }} 
  {{= $closingBraces }}
  if ({{=$errs}} == errors) {
{{?}}

{{# def.cleanUp }}