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
|
Rev | Line | |
---|
[6a3a178] | 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 { 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 | };
|
---|
| 23 | exports.default = def;
|
---|
| 24 | //# sourceMappingURL=pattern.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.