1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | const codegen_1 = require("../../compile/codegen");
|
---|
4 | const ops = codegen_1.operators;
|
---|
5 | const KWDs = {
|
---|
6 | maximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT },
|
---|
7 | minimum: { okStr: ">=", ok: ops.GTE, fail: ops.LT },
|
---|
8 | exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
|
---|
9 | exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE },
|
---|
10 | };
|
---|
11 | const error = {
|
---|
12 | message: ({ keyword, schemaCode }) => (0, codegen_1.str) `must be ${KWDs[keyword].okStr} ${schemaCode}`,
|
---|
13 | params: ({ keyword, schemaCode }) => (0, codegen_1._) `{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`,
|
---|
14 | };
|
---|
15 | const def = {
|
---|
16 | keyword: Object.keys(KWDs),
|
---|
17 | type: "number",
|
---|
18 | schemaType: "number",
|
---|
19 | $data: true,
|
---|
20 | error,
|
---|
21 | code(cxt) {
|
---|
22 | const { keyword, data, schemaCode } = cxt;
|
---|
23 | cxt.fail$data((0, codegen_1._) `${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
|
---|
24 | },
|
---|
25 | };
|
---|
26 | exports.default = def;
|
---|
27 | //# sourceMappingURL=limitNumber.js.map |
---|