Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | const codegen_1 = require("../../compile/codegen");
|
---|
4 | const util_1 = require("../../compile/util");
|
---|
5 | const ucs2length_1 = require("../../runtime/ucs2length");
|
---|
6 | const error = {
|
---|
7 | message({ keyword, schemaCode }) {
|
---|
8 | const comp = keyword === "maxLength" ? "more" : "fewer";
|
---|
9 | return codegen_1.str `must NOT have ${comp} than ${schemaCode} characters`;
|
---|
10 | },
|
---|
11 | params: ({ schemaCode }) => codegen_1._ `{limit: ${schemaCode}}`,
|
---|
12 | };
|
---|
13 | const def = {
|
---|
14 | keyword: ["maxLength", "minLength"],
|
---|
15 | type: "string",
|
---|
16 | schemaType: "number",
|
---|
17 | $data: true,
|
---|
18 | error,
|
---|
19 | code(cxt) {
|
---|
20 | const { keyword, data, schemaCode, it } = cxt;
|
---|
21 | const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
---|
22 | const len = it.opts.unicode === false ? codegen_1._ `${data}.length` : codegen_1._ `${util_1.useFunc(cxt.gen, ucs2length_1.default)}(${data})`;
|
---|
23 | cxt.fail$data(codegen_1._ `${len} ${op} ${schemaCode}`);
|
---|
24 | },
|
---|
25 | };
|
---|
26 | exports.default = def;
|
---|
27 | //# sourceMappingURL=limitLength.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.