ajv/lib/dot/dependencies.jst

61 lines
1.3 KiB
Plaintext
Raw Normal View History

{{# def.definitions }}
2015-12-12 16:41:51 +03:00
{{# def.errors }}
{{# def.missing }}
{{# def.setup:'dependencies' }}
{{# def.setupNextLevel }}
2015-06-01 22:44:12 +03:00
{{
var $schemaDeps = {}
, $propertyDeps = {};
for ($property in $schema) {
var $sch = $schema[$property];
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
$deps[$property] = $sch;
2015-06-01 22:44:12 +03:00
}
}}
var {{=$errs}} = errors;
2015-06-02 03:59:32 +03:00
{{ var $currentErrorPath = it.errorPath; }}
2015-06-02 03:59:32 +03:00
var missing{{=$lvl}};
{{ for (var $property in $propertyDeps) { }}
if ({{=$data}}{{= it.util.getProperty($property) }} !== undefined) {
2015-06-01 22:44:12 +03:00
{{ $deps = $propertyDeps[$property]; }}
if ({{# def.checkMissingProperty:$deps }}) {
{{# def.errorMissingProperty }}
{{# def.error:'dependencies' }}
} {{# def.elseIfValid }}
2015-06-01 22:44:12 +03:00
}
{{ } }}
{{ it.errorPath = $currentErrorPath; }}
2015-06-01 22:44:12 +03:00
{{ for (var $property in $schemaDeps) { }}
{{ var $sch = $schemaDeps[$property]; }}
{{? {{# def.nonEmptySchema:$sch }} }}
2015-06-06 04:07:50 +03:00
valid{{=$it.level}} = true;
if ({{=$data}}['{{= $property }}'] !== undefined) {
{{
$it.schema = $sch;
$it.schemaPath = $schemaPath + it.util.getProperty($property);
}}
{{= it.validate($it) }}
}
2015-06-06 04:07:50 +03:00
{{# def.ifResultValid }}
{{?}}
2015-06-01 22:44:12 +03:00
{{ } }}
{{? $breakOnError }}
{{= $closingBraces }}
if ({{=$errs}} == errors) {
{{?}}
2015-06-02 03:59:32 +03:00
{{# def.cleanUp }}