main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[79a0317] | 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 (0, codegen_1.str) `must NOT have ${comp} than ${schemaCode} characters`;
|
---|
| 10 | },
|
---|
| 11 | params: ({ schemaCode }) => (0, 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 ? (0, codegen_1._) `${data}.length` : (0, codegen_1._) `${(0, util_1.useFunc)(cxt.gen, ucs2length_1.default)}(${data})`;
|
---|
| 23 | cxt.fail$data((0, 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.