source: trip-planner-front/node_modules/ajv/dist/vocabularies/validation/pattern.js

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

initial commit

  • Property mode set to 100644
File size: 880 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const code_1 = require("../code");
4const codegen_1 = require("../../compile/codegen");
5const error = {
6 message: ({ schemaCode }) => codegen_1.str `must match pattern "${schemaCode}"`,
7 params: ({ schemaCode }) => codegen_1._ `{pattern: ${schemaCode}}`,
8};
9const def = {
10 keyword: "pattern",
11 type: "string",
12 schemaType: "string",
13 $data: true,
14 error,
15 code(cxt) {
16 const { data, $data, schema, schemaCode, it } = cxt;
17 // TODO regexp should be wrapped in try/catchs
18 const u = it.opts.unicodeRegExp ? "u" : "";
19 const regExp = $data ? codegen_1._ `(new RegExp(${schemaCode}, ${u}))` : code_1.usePattern(cxt, schema);
20 cxt.fail$data(codegen_1._ `!${regExp}.test(${data})`);
21 },
22};
23exports.default = def;
24//# sourceMappingURL=pattern.js.map
Note: See TracBrowser for help on using the repository browser.