Path: blob/master/node_modules/ajv/lib/dotjs/allOf.js
2593 views
'use strict';1module.exports = function generate_allOf(it, $keyword, $ruleType) {2var out = ' ';3var $schema = it.schema[$keyword];4var $schemaPath = it.schemaPath + it.util.getProperty($keyword);5var $errSchemaPath = it.errSchemaPath + '/' + $keyword;6var $breakOnError = !it.opts.allErrors;7var $it = it.util.copy(it);8var $closingBraces = '';9$it.level++;10var $nextValid = 'valid' + $it.level;11var $currentBaseId = $it.baseId,12$allSchemasEmpty = true;13var arr1 = $schema;14if (arr1) {15var $sch, $i = -1,16l1 = arr1.length - 1;17while ($i < l1) {18$sch = arr1[$i += 1];19if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {20$allSchemasEmpty = false;21$it.schema = $sch;22$it.schemaPath = $schemaPath + '[' + $i + ']';23$it.errSchemaPath = $errSchemaPath + '/' + $i;24out += ' ' + (it.validate($it)) + ' ';25$it.baseId = $currentBaseId;26if ($breakOnError) {27out += ' if (' + ($nextValid) + ') { ';28$closingBraces += '}';29}30}31}32}33if ($breakOnError) {34if ($allSchemasEmpty) {35out += ' if (true) { ';36} else {37out += ' ' + ($closingBraces.slice(0, -1)) + ' ';38}39}40return out;41}424344