source: trip-planner-front/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js@ 84d0fbb

Last change on this file since 84d0fbb was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.dynamicAnchor = void 0;
4const codegen_1 = require("../../compile/codegen");
5const names_1 = require("../../compile/names");
6const compile_1 = require("../../compile");
7const ref_1 = require("../core/ref");
8const def = {
9 keyword: "$dynamicAnchor",
10 schemaType: "string",
11 code: (cxt) => dynamicAnchor(cxt, cxt.schema),
12};
13function dynamicAnchor(cxt, anchor) {
14 const { gen, it } = cxt;
15 it.schemaEnv.root.dynamicAnchors[anchor] = true;
16 const v = codegen_1._ `${names_1.default.dynamicAnchors}${codegen_1.getProperty(anchor)}`;
17 const validate = it.errSchemaPath === "#" ? it.validateName : _getValidate(cxt);
18 gen.if(codegen_1._ `!${v}`, () => gen.assign(v, validate));
19}
20exports.dynamicAnchor = dynamicAnchor;
21function _getValidate(cxt) {
22 const { schemaEnv, schema, self } = cxt.it;
23 const { root, baseId, localRefs, meta } = schemaEnv.root;
24 const { schemaId } = self.opts;
25 const sch = new compile_1.SchemaEnv({ schema, schemaId, root, baseId, localRefs, meta });
26 compile_1.compileSchema.call(self, sch);
27 return ref_1.getValidate(cxt, sch);
28}
29exports.default = def;
30//# sourceMappingURL=dynamicAnchor.js.map
Note: See TracBrowser for help on using the repository browser.