source: trip-planner-front/node_modules/ajv/dist/vocabularies/applicator/properties.js@ 6a80231

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

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const validate_1 = require("../../compile/validate");
4const code_1 = require("../code");
5const util_1 = require("../../compile/util");
6const additionalProperties_1 = require("./additionalProperties");
7const def = {
8 keyword: "properties",
9 type: "object",
10 schemaType: "object",
11 code(cxt) {
12 const { gen, schema, parentSchema, data, it } = cxt;
13 if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === undefined) {
14 additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties"));
15 }
16 const allProps = code_1.allSchemaProperties(schema);
17 for (const prop of allProps) {
18 it.definedProperties.add(prop);
19 }
20 if (it.opts.unevaluated && allProps.length && it.props !== true) {
21 it.props = util_1.mergeEvaluated.props(gen, util_1.toHash(allProps), it.props);
22 }
23 const properties = allProps.filter((p) => !util_1.alwaysValidSchema(it, schema[p]));
24 if (properties.length === 0)
25 return;
26 const valid = gen.name("valid");
27 for (const prop of properties) {
28 if (hasDefault(prop)) {
29 applyPropertySchema(prop);
30 }
31 else {
32 gen.if(code_1.propertyInData(gen, data, prop, it.opts.ownProperties));
33 applyPropertySchema(prop);
34 if (!it.allErrors)
35 gen.else().var(valid, true);
36 gen.endIf();
37 }
38 cxt.it.definedProperties.add(prop);
39 cxt.ok(valid);
40 }
41 function hasDefault(prop) {
42 return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== undefined;
43 }
44 function applyPropertySchema(prop) {
45 cxt.subschema({
46 keyword: "properties",
47 schemaProp: prop,
48 dataProp: prop,
49 }, valid);
50 }
51 },
52};
53exports.default = def;
54//# sourceMappingURL=properties.js.map
Note: See TracBrowser for help on using the repository browser.