61 lines
1.8 KiB
Plaintext
61 lines
1.8 KiB
Plaintext
{{# def.definitions }}
|
|
{{# def.setup:'$ref' }}
|
|
|
|
{{## def.validateRef:_v:
|
|
if (!{{# def._validateRef:_v }}) {
|
|
if (vErrors === null) vErrors = {{=_v}}.errors;
|
|
else vErrors = vErrors.concat({{=_v}}.errors);
|
|
errors = vErrors.length;
|
|
} {{? $breakOnError }} else { {{?}}
|
|
#}}
|
|
|
|
{{## def._validateRef:_v: {{=_v}}({{=$data}}, (dataPath || ''){{? it.errorPath != '""'}} + {{= it.errorPath }}{{?}}) #}}
|
|
|
|
{{? $schema == '#' || $schema == '#/' }}
|
|
{{? it.isRoot }}
|
|
{{# def.validateRef:'validate' }}
|
|
{{??}}
|
|
{{# def.validateRef:'root.refVal[0]' }}
|
|
{{?}}
|
|
{{??}}
|
|
{{ var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); }}
|
|
{{? $refVal === undefined }}
|
|
{{ 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) { {{?}}
|
|
{{??}}
|
|
{{
|
|
var $error = new Error($message);
|
|
$error.missingRef = it.resolve.url(it.baseId, $schema);
|
|
$error.missingSchema = it.resolve.normalizeId(it.resolve.fullPath($error.missingRef));
|
|
throw $error;
|
|
}}
|
|
{{?}}
|
|
{{?? typeof $refVal == 'string' }}
|
|
{{# def.validateRef:$refVal }}
|
|
{{??}}
|
|
{{# def.setupNextLevel }}
|
|
{{
|
|
$it.schema = $refVal.schema;
|
|
$it.schemaPath = '';
|
|
}}
|
|
{{ var $code = it.validate($it); }}
|
|
{{? /validate\.schema/.test($code) }}
|
|
var rootSchema{{=$it.level}} = validate.schema;
|
|
validate.schema = {{=$refVal.code}};
|
|
{{= $code }}
|
|
validate.schema = rootSchema{{=$it.level}};
|
|
{{??}}
|
|
{{= $code }}
|
|
{{?}}
|
|
{{? $breakOnError}}
|
|
if (valid{{=$it.level}}) {
|
|
{{?}}
|
|
{{?}}
|
|
{{?}}
|