3 {{# def.setupKeyword }}
5 {{## def._validateRef:_v:
6 {{? it.opts.passContext }}
11 {{=$data}}, {{# def.dataPath }}{{# def.passParentData }}, rootData)
14 {{ var $async, $refCode; }}
15 {{? $schema == '#' || $schema == '#/' }}
19 $refCode = 'validate';
21 $async = it.root.schema.$async === true;
22 $refCode = 'root.refVal[0]';
26 {{ var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot); }}
27 {{? $refVal === undefined }}
28 {{ var $message = 'can\'t resolve reference ' + $schema + ' from id ' + it.baseId; }}
29 {{? it.opts.missingRefs == 'fail' }}
30 {{ console.log($message); }}
31 {{# def.error:'$ref' }}
32 {{? $breakOnError }} if (false) { {{?}}
33 {{?? it.opts.missingRefs == 'ignore' }}
34 {{ console.log($message); }}
35 {{? $breakOnError }} if (true) { {{?}}
38 var $error = new Error($message);
39 $error.missingRef = it.resolve.url(it.baseId, $schema);
40 $error.missingSchema = it.resolve.normalizeId(it.resolve.fullPath($error.missingRef));
44 {{?? $refVal.inline }}
45 {{# def.setupNextLevel }}
47 $it.schema = $refVal.schema;
49 $it.errSchemaPath = $schema;
51 {{ var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code); }}
54 if ({{=$nextValid}}) {
58 $async = $refVal.$async === true;
59 $refCode = $refVal.code;
66 {{# def._validateRef:$refCode }}
67 {{# def.storeDefOut:__callValidate }}
70 {{ if (!it.async) throw new Error('async schema referenced by sync schema'); }}
71 try { {{? $breakOnError }}var {{=$valid}} ={{?}} {{=it.yieldAwait}} {{=__callValidate}}; }
73 if (!(e instanceof ValidationError)) throw e;
74 if (vErrors === null) vErrors = e.errors;
75 else vErrors = vErrors.concat(e.errors);
76 errors = vErrors.length;
78 {{? $breakOnError }} if ({{=$valid}}) { {{?}}
80 if (!{{=__callValidate}}) {
81 if (vErrors === null) vErrors = {{=$refCode}}.errors;
82 else vErrors = vErrors.concat({{=$refCode}}.errors);
83 errors = vErrors.length;
84 } {{? $breakOnError }} else { {{?}}