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:
1021 bytes
|
Rev | Line | |
---|
[6a3a178] | 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 }) => codegen_1.str `must be ${KWDs[keyword].okStr} ${schemaCode}`,
|
---|
| 13 | params: ({ keyword, schemaCode }) => 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(codegen_1._ `${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
|
---|
| 24 | },
|
---|
| 25 | };
|
---|
| 26 | exports.default = def;
|
---|
| 27 | //# sourceMappingURL=limitNumber.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.