source: trip-planner-front/node_modules/ajv/dist/vocabularies/validation/limitLength.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: 1.1 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const codegen_1 = require("../../compile/codegen");
4const util_1 = require("../../compile/util");
5const ucs2length_1 = require("../../runtime/ucs2length");
6const 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};
13const 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};
26exports.default = def;
27//# sourceMappingURL=limitLength.js.map
Note: See TracBrowser for help on using the repository browser.