3 {{# def.setupKeyword }}
4 {{# def.setupNextLevel }}
7 {{## def.validateItems:startFrom:
8 for (var {{=$idx}} = {{=startFrom}}; {{=$idx}} < {{=$data}}.length; {{=$idx}}++) {
10 $it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
11 var $passData = $data + '[' + $idx + ']';
12 $it.dataPathArr[$dataNxt] = $idx;
15 {{# def.generateSubschemaCode }}
16 {{# def.optimizeValidate }}
19 if (!{{=$nextValid}}) break;
26 , $dataNxt = $it.dataLevel = it.dataLevel + 1
27 , $nextData = 'data' + $dataNxt
28 , $currentBaseId = it.baseId;
31 var {{=$errs}} = errors;
34 {{? Array.isArray($schema) }}
35 {{ /* 'items' is an array of schemas */}}
36 {{ var $additionalItems = it.schema.additionalItems; }}
37 {{? $additionalItems === false }}
38 {{=$valid}} = {{=$data}}.length <= {{= $schema.length }};
40 var $currErrSchemaPath = $errSchemaPath;
41 $errSchemaPath = it.errSchemaPath + '/additionalItems';
43 {{# def.checkError:'additionalItems' }}
44 {{ $errSchemaPath = $currErrSchemaPath; }}
48 {{~ $schema:$sch:$i }}
49 {{? {{# def.nonEmptySchema:$sch }} }}
50 {{=$nextValid}} = true;
52 if ({{=$data}}.length > {{=$i}}) {
54 var $passData = $data + '[' + $i + ']';
56 $it.schemaPath = $schemaPath + '[' + $i + ']';
57 $it.errSchemaPath = $errSchemaPath + '/' + $i;
58 $it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
59 $it.dataPathArr[$dataNxt] = $i;
62 {{# def.generateSubschemaCode }}
63 {{# def.optimizeValidate }}
66 {{# def.ifResultValid }}
70 {{? typeof $additionalItems == 'object' && {{# def.nonEmptySchema:$additionalItems }} }}
72 $it.schema = $additionalItems;
73 $it.schemaPath = it.schemaPath + '.additionalItems';
74 $it.errSchemaPath = it.errSchemaPath + '/additionalItems';
76 {{=$nextValid}} = true;
78 if ({{=$data}}.length > {{= $schema.length }}) {
79 {{# def.validateItems: $schema.length }}
82 {{# def.ifResultValid }}
85 {{?? {{# def.nonEmptySchema:$schema }} }}
86 {{ /* 'items' is a single schema */}}
89 $it.schemaPath = $schemaPath;
90 $it.errSchemaPath = $errSchemaPath;
92 {{# def.validateItems: 0 }}
97 if ({{=$errs}} == errors) {