.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / table / node_modules / ajv / dist / vocabularies / validation / pattern.js
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 const code_1 = require("../code");
4 const codegen_1 = require("../../compile/codegen");
5 const error = {
6     message: ({ schemaCode }) => codegen_1.str `must match pattern "${schemaCode}"`,
7     params: ({ schemaCode }) => codegen_1._ `{pattern: ${schemaCode}}`,
8 };
9 const def = {
10     keyword: "pattern",
11     type: "string",
12     schemaType: "string",
13     $data: true,
14     error,
15     code(cxt) {
16         const { gen, data, $data, schema, schemaCode } = cxt;
17         const regExp = $data ? codegen_1._ `(new RegExp(${schemaCode}, "u"))` : code_1.usePattern(gen, schema); // TODO regexp should be wrapped in try/catch
18         cxt.fail$data(codegen_1._ `!${regExp}.test(${data})`);
19     },
20 };
21 exports.default = def;
22 //# sourceMappingURL=pattern.js.map