source: imaps-frontend/node_modules/ajv-keywords/dist/definitions/regexp.js@ 79a0317

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 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 regexpMetaSchema = {
6 type: "object",
7 properties: {
8 pattern: { type: "string" },
9 flags: { type: "string", nullable: true },
10 },
11 required: ["pattern"],
12 additionalProperties: false,
13};
14const metaRegexp = /^\/(.*)\/([gimuy]*)$/;
15function getDef() {
16 return {
17 keyword: "regexp",
18 type: "string",
19 schemaType: ["string", "object"],
20 code(cxt) {
21 const { data, schema } = cxt;
22 const regx = getRegExp(schema);
23 cxt.pass((0, codegen_1._) `${regx}.test(${data})`);
24 function getRegExp(sch) {
25 if (typeof sch == "object")
26 return (0, _util_1.usePattern)(cxt, sch.pattern, sch.flags);
27 const rx = metaRegexp.exec(sch);
28 if (rx)
29 return (0, _util_1.usePattern)(cxt, rx[1], rx[2]);
30 throw new Error("cannot parse string into RegExp");
31 }
32 },
33 metaSchema: {
34 anyOf: [{ type: "string" }, regexpMetaSchema],
35 },
36 };
37}
38exports.default = getDef;
39module.exports = getDef;
40//# sourceMappingURL=regexp.js.map
Note: See TracBrowser for help on using the repository browser.