'use strict'; module.exports = function generate_dependencies(it, $keyword, $ruleType) { var out=' '; var $lvl = it.level; var $dataLvl = it.dataLevel; var $schema = it.schema[$keyword]; var $schemaPath = it.schemaPath + it.util.getProperty($keyword); var $errSchemaPath = it.errSchemaPath + '/' + $keyword; var $breakOnError = !it.opts.allErrors; var $data = 'data' + ($dataLvl || ''); var $errs = 'errs__' + $lvl; var $it = it.util.copy(it); var $closingBraces = ''; $it.level++; var $nextValid = 'valid' + $it.level; var $schemaDeps = {} , $propertyDeps = {} , $ownProperties = it.opts.ownProperties; for ($property in $schema) { if ($property == '__proto__') continue; var $sch = $schema[$property]; var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps; $deps[$property] = $sch; }out+='var '+($errs)+' = errors;'; var $currentErrorPath = it.errorPath; out+='var missing'+($lvl)+';'; for (var $property in $propertyDeps) { $deps = $propertyDeps[$property]; if($deps.length){out+=' if ( '+($data)+( it.util.getProperty($property) )+' !== undefined ';if($ownProperties){out+=' && Object.prototype.hasOwnProperty.call('+($data)+', \''+(it.util.escapeQuotes($property))+'\') ';}if($breakOnError){out+=' && ( ';var arr1=$deps;if(arr1){var $propertyKey,$i=-1,l1=arr1.length-1;while($i 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))){out+=' '+($nextValid)+' = true; if ( '+($data)+( it.util.getProperty($property) )+' !== undefined ';if($ownProperties){out+=' && Object.prototype.hasOwnProperty.call('+($data)+', \''+(it.util.escapeQuotes($property))+'\') ';}out+=') { '; $it.schema = $sch; $it.schemaPath = $schemaPath + it.util.getProperty($property); $it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($property); out+=' '+( it.validate($it) )+' '; $it.baseId = $currentBaseId; out+=' } ';if($breakOnError){out+=' if ('+($nextValid)+') { '; $closingBraces += '}'; }} } if($breakOnError){out+=' '+( $closingBraces )+' if ('+($errs)+' == errors) {';}return out; }