source: imaps-frontend/node_modules/ajv-keywords/dist/definitions/patternRequired.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const codegen_1 = require("ajv/dist/compile/codegen");
4const _util_1 = require("./_util");
5const error = {
6 message: ({ params: { missingPattern } }) => (0, codegen_1.str) `should have property matching pattern '${missingPattern}'`,
7 params: ({ params: { missingPattern } }) => (0, codegen_1._) `{missingPattern: ${missingPattern}}`,
8};
9function getDef() {
10 return {
11 keyword: "patternRequired",
12 type: "object",
13 schemaType: "array",
14 error,
15 code(cxt) {
16 const { gen, schema, data } = cxt;
17 if (schema.length === 0)
18 return;
19 const valid = gen.let("valid", true);
20 for (const pat of schema)
21 validateProperties(pat);
22 function validateProperties(pattern) {
23 const matched = gen.let("matched", false);
24 gen.forIn("key", data, (key) => {
25 gen.assign(matched, (0, codegen_1._) `${(0, _util_1.usePattern)(cxt, pattern)}.test(${key})`);
26 gen.if(matched, () => gen.break());
27 });
28 cxt.setParams({ missingPattern: pattern });
29 gen.assign(valid, (0, codegen_1.and)(valid, matched));
30 cxt.pass(valid);
31 }
32 },
33 metaSchema: {
34 type: "array",
35 items: { type: "string", format: "regex" },
36 uniqueItems: true,
37 },
38 };
39}
40exports.default = getDef;
41module.exports = getDef;
42//# sourceMappingURL=patternRequired.js.map
Note: See TracBrowser for help on using the repository browser.