source: trip-planner-front/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js@ eed0bf8

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

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const codegen_1 = require("../../compile/codegen");
4const util_1 = require("../../compile/util");
5const error = {
6 message: ({ params: { len } }) => codegen_1.str `must NOT have more than ${len} items`,
7 params: ({ params: { len } }) => codegen_1._ `{limit: ${len}}`,
8};
9const def = {
10 keyword: "unevaluatedItems",
11 type: "array",
12 schemaType: ["boolean", "object"],
13 error,
14 code(cxt) {
15 const { gen, schema, data, it } = cxt;
16 const items = it.items || 0;
17 if (items === true)
18 return;
19 const len = gen.const("len", codegen_1._ `${data}.length`);
20 if (schema === false) {
21 cxt.setParams({ len: items });
22 cxt.fail(codegen_1._ `${len} > ${items}`);
23 }
24 else if (typeof schema == "object" && !util_1.alwaysValidSchema(it, schema)) {
25 const valid = gen.var("valid", codegen_1._ `${len} <= ${items}`);
26 gen.if(codegen_1.not(valid), () => validateItems(valid, items));
27 cxt.ok(valid);
28 }
29 it.items = true;
30 function validateItems(valid, from) {
31 gen.forRange("i", from, len, (i) => {
32 cxt.subschema({ keyword: "unevaluatedItems", dataProp: i, dataPropType: util_1.Type.Num }, valid);
33 if (!it.allErrors)
34 gen.if(codegen_1.not(valid), () => gen.break());
35 });
36 }
37 },
38};
39exports.default = def;
40//# sourceMappingURL=unevaluatedItems.js.map
Note: See TracBrowser for help on using the repository browser.