ajv/lib/dot/ref.jst

55 lines
1.5 KiB
Plaintext
Raw Normal View History

{{# def.definitions }}
{{# def.setup:'$ref' }}
2015-06-17 00:04:17 +03:00
{{## def.validateRef:_v:
if (!{{# def._validateRef:_v }}) {
if (vErrors === null) vErrors = {{=_v}}.errors;
else vErrors = vErrors.concat({{=_v}}.errors);
errors = vErrors.length;
2015-06-17 00:04:17 +03:00
} {{? $breakOnError }} else { {{?}}
#}}
{{## def._validateRef:_v: {{=_v}}({{=$data}}, (dataPath || ''){{? it.errorPath != '""'}} + {{= it.errorPath }}{{?}}) #}}
2015-06-17 00:04:17 +03:00
{{? $schema == '#' || $schema == '#/' }}
{{? it.isRoot }}
{{? $breakOnError && it.wasTop }}
2015-06-17 00:04:17 +03:00
if (!{{# def._validateRef:'validate' }})
return false;
else {
{{??}}
{{# def.validateRef:'validate' }}
{{?}}
2015-06-15 18:30:48 +03:00
{{??}}
{{# def.validateRef:'root.refVal[0]' }}
2015-06-15 18:30:48 +03:00
{{?}}
2015-05-31 20:39:12 +03:00
{{??}}
{{ var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); }}
{{? $refVal === undefined }}
2015-06-18 16:59:11 +03:00
{{ var $message = 'can\'t resolve reference ' + $schema + ' from id ' + it.baseId; }}
{{? it.opts.missingRefs == 'fail' }}
{{ console.log($message); }}
{{# def.error:'$ref' }}
{{? $breakOnError }} if (false) { {{?}}
{{?? it.opts.missingRefs == 'ignore' }}
{{ console.log($message); }}
{{? $breakOnError }} if (true) { {{?}}
{{??}}
{{ throw new Error($message); }}
{{?}}
2015-08-20 00:54:05 +03:00
{{?? typeof $refVal == 'string' }}
{{# def.validateRef:$refVal }}
2015-08-20 00:54:05 +03:00
{{??}}
{{ /* console.log('inline: ', $refVal); */ }}
{{# def.setupNextLevel }}
{{
$it.schema = $refVal;
$it.schemaPath = '';
}}
{{= it.validate($it) }}
{{? $breakOnError}}
if (valid{{=$it.level}}) {
{{?}}
2015-06-06 18:18:52 +03:00
{{?}}
2015-05-31 20:39:12 +03:00
{{?}}