2015-06-03 03:36:59 +03:00
|
|
|
{{# def.definitions }}
|
2015-12-12 16:41:51 +03:00
|
|
|
{{# def.errors }}
|
2015-12-22 20:03:09 +03:00
|
|
|
{{# def.setupKeyword }}
|
2015-06-03 03:36:59 +03:00
|
|
|
|
2016-01-17 16:50:54 +03:00
|
|
|
{{## def._validateRef:_v:
|
2016-02-14 23:34:10 +03:00
|
|
|
{{? it.opts.passContext }}
|
|
|
|
{{=_v}}.call(this,
|
|
|
|
{{??}}
|
|
|
|
{{=_v}}(
|
|
|
|
{{?}}
|
2016-08-29 23:51:49 +03:00
|
|
|
{{=$data}}, {{# def.dataPath }}{{# def.passParentData }}, rootData)
|
2016-01-17 16:50:54 +03:00
|
|
|
#}}
|
2015-06-17 00:04:17 +03:00
|
|
|
|
2016-01-28 02:43:28 +03:00
|
|
|
{{ var $async, $refCode; }}
|
2015-06-06 21:44:07 +03:00
|
|
|
{{? $schema == '#' || $schema == '#/' }}
|
2016-01-28 02:43:28 +03:00
|
|
|
{{
|
|
|
|
if (it.isRoot) {
|
|
|
|
$async = it.async;
|
|
|
|
$refCode = 'validate';
|
|
|
|
} else {
|
|
|
|
$async = it.root.schema.$async === true;
|
|
|
|
$refCode = 'root.refVal[0]';
|
|
|
|
}
|
|
|
|
}}
|
2015-05-31 20:39:12 +03:00
|
|
|
{{??}}
|
2015-08-08 14:21:41 +03:00
|
|
|
{{ var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); }}
|
2015-06-16 17:10:21 +03:00
|
|
|
{{? $refVal === undefined }}
|
2016-11-25 23:25:19 +03:00
|
|
|
{{ var $message = it.MissingRefError.message(it.baseId, $schema); }}
|
2015-06-18 00:23:49 +03:00
|
|
|
{{? it.opts.missingRefs == 'fail' }}
|
2017-11-19 12:18:40 +03:00
|
|
|
{{ it.logger.error($message); }}
|
2015-06-18 00:23:49 +03:00
|
|
|
{{# def.error:'$ref' }}
|
|
|
|
{{? $breakOnError }} if (false) { {{?}}
|
|
|
|
{{?? it.opts.missingRefs == 'ignore' }}
|
2017-11-19 12:18:40 +03:00
|
|
|
{{ it.logger.warn($message); }}
|
2015-06-18 00:23:49 +03:00
|
|
|
{{? $breakOnError }} if (true) { {{?}}
|
|
|
|
{{??}}
|
2016-11-25 23:25:19 +03:00
|
|
|
{{ throw new it.MissingRefError(it.baseId, $schema, $message); }}
|
2015-06-18 00:23:49 +03:00
|
|
|
{{?}}
|
2016-01-28 02:43:28 +03:00
|
|
|
{{?? $refVal.inline }}
|
2015-08-20 00:54:05 +03:00
|
|
|
{{# def.setupNextLevel }}
|
|
|
|
{{
|
2015-08-22 00:52:29 +03:00
|
|
|
$it.schema = $refVal.schema;
|
2015-08-20 00:54:05 +03:00
|
|
|
$it.schemaPath = '';
|
2015-12-19 18:56:08 +03:00
|
|
|
$it.errSchemaPath = $schema;
|
2015-08-20 00:54:05 +03:00
|
|
|
}}
|
2015-11-27 01:49:49 +03:00
|
|
|
{{ var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code); }}
|
|
|
|
{{= $code }}
|
2015-08-20 00:54:05 +03:00
|
|
|
{{? $breakOnError}}
|
2016-12-24 01:02:41 +03:00
|
|
|
if ({{=$nextValid}}) {
|
2015-08-20 00:54:05 +03:00
|
|
|
{{?}}
|
2016-01-28 02:43:28 +03:00
|
|
|
{{??}}
|
|
|
|
{{
|
2017-12-02 13:24:27 +03:00
|
|
|
$async = $refVal.$async === true || (it.async && $refVal.$async !== false);
|
2016-01-28 02:43:28 +03:00
|
|
|
$refCode = $refVal.code;
|
|
|
|
}}
|
|
|
|
{{?}}
|
|
|
|
{{?}}
|
|
|
|
|
|
|
|
{{? $refCode }}
|
|
|
|
{{# def.beginDefOut}}
|
|
|
|
{{# def._validateRef:$refCode }}
|
|
|
|
{{# def.storeDefOut:__callValidate }}
|
|
|
|
|
|
|
|
{{? $async }}
|
|
|
|
{{ if (!it.async) throw new Error('async schema referenced by sync schema'); }}
|
2016-12-25 23:24:36 +03:00
|
|
|
{{? $breakOnError }} var {{=$valid}}; {{?}}
|
|
|
|
try {
|
2017-11-06 00:14:31 +03:00
|
|
|
await {{=__callValidate}};
|
2016-12-25 23:24:36 +03:00
|
|
|
{{? $breakOnError }} {{=$valid}} = true; {{?}}
|
|
|
|
} catch (e) {
|
2016-01-28 02:43:28 +03:00
|
|
|
if (!(e instanceof ValidationError)) throw e;
|
|
|
|
if (vErrors === null) vErrors = e.errors;
|
|
|
|
else vErrors = vErrors.concat(e.errors);
|
|
|
|
errors = vErrors.length;
|
2016-12-25 23:24:36 +03:00
|
|
|
{{? $breakOnError }} {{=$valid}} = false; {{?}}
|
2016-01-28 02:43:28 +03:00
|
|
|
}
|
|
|
|
{{? $breakOnError }} if ({{=$valid}}) { {{?}}
|
|
|
|
{{??}}
|
|
|
|
if (!{{=__callValidate}}) {
|
|
|
|
if (vErrors === null) vErrors = {{=$refCode}}.errors;
|
|
|
|
else vErrors = vErrors.concat({{=$refCode}}.errors);
|
|
|
|
errors = vErrors.length;
|
|
|
|
} {{? $breakOnError }} else { {{?}}
|
2015-06-06 18:18:52 +03:00
|
|
|
{{?}}
|
2015-05-31 20:39:12 +03:00
|
|
|
{{?}}
|