4 var $dataLvl = it.dataLevel;
5 var $schema = it.schema[$keyword];
6 var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
7 var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
8 var $breakOnError = !it.opts.allErrors;
11 var $data = 'data' + ($dataLvl || '');
12 var $valid = 'valid' + $lvl;
13 var $errs = 'errs__' + $lvl;
18 {{## def.setCompositeRule:
20 var $wasComposite = it.compositeRule;
21 it.compositeRule = $it.compositeRule = true;
26 {{## def.resetCompositeRule:
27 {{ it.compositeRule = $it.compositeRule = $wasComposite; }}
31 {{## def.setupNextLevel:
33 var $it = it.util.copy(it);
34 var $closingBraces = '';
36 var $nextValid = 'valid' + $it.level;
44 {{ $closingBraces += '}'; }}
49 {{## def.ifResultValid:
51 if ({{=$nextValid}}) {
52 {{ $closingBraces += '}'; }}
59 {{ $closingBraces += '}'; }}
65 {{## def.nonEmptySchema:_schema:
66 it.util.schemaHasRules(_schema, it.RULES.all)
71 {{? it.opts.unicode === false }}
74 ucs2length({{=$data}})
79 {{## def.willOptimize:
80 it.util.varOccurences($code, $nextData) < 2
84 {{## def.generateSubschemaCode:
86 var $code = it.validate($it);
87 $it.baseId = $currentBaseId;
92 {{## def.insertSubschemaCode:
93 {{= it.validate($it) }}
94 {{ $it.baseId = $currentBaseId; }}
98 {{## def._optimizeValidate:
99 it.util.varReplace($code, $nextData, $passData)
103 {{## def.optimizeValidate:
104 {{? {{# def.willOptimize}} }}
105 {{= {{# def._optimizeValidate }} }}
107 var {{=$nextData}} = {{=$passData}};
113 {{## def.cleanUp: {{ out = it.util.cleanUpCode(out); }} #}}
116 {{## def.cleanUpVarErrors: {{ out = it.util.cleanUpVarErrors(out, $async); }} #}}
121 var $isData = it.opts.v5 && $schema && $schema.$data
125 var schema{{=$lvl}} = {{= it.util.getData($schema.$data, $dataLvl, it.dataPathArr) }};
126 {{ $schemaValue = 'schema' + $lvl; }}
128 {{ $schemaValue = $schema; }}
133 {{## def.$dataNotType:_type:
134 {{?$isData}} ({{=$schemaValue}} !== undefined && typeof {{=$schemaValue}} != _type) || {{?}}
138 {{## def.check$dataIsArray:
139 if (schema{{=$lvl}} === undefined) {{=$valid}} = true;
140 else if (!Array.isArray(schema{{=$lvl}})) {{=$valid}} = false;
145 {{## def.beginDefOut:
147 var $$outStack = $$outStack || [];
148 $$outStack.push(out);
154 {{## def.storeDefOut:_variable:
157 out = $$outStack.pop();
162 {{## def.dataPath:(dataPath || ''){{? it.errorPath != '""'}} + {{= it.errorPath }}{{?}}#}}
164 {{## def.setParentData:
166 var $parentData = $dataLvl ? 'data' + (($dataLvl-1)||'') : 'parentData'
167 , $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : 'parentDataProperty';
171 {{## def.passParentData:
172 {{# def.setParentData }}
174 , {{= $parentDataProperty }}
178 {{## def.checkOwnProperty:
179 {{? $ownProperties }}
180 if (!Object.prototype.hasOwnProperty.call({{=$data}}, {{=$key}})) continue;