1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function getRangeDef(keyword) {
|
4 | return () => ({
|
5 | keyword,
|
6 | type: "number",
|
7 | schemaType: "array",
|
8 | macro: function ([min, max]) {
|
9 | validateRangeSchema(min, max);
|
10 | return keyword === "range"
|
11 | ? { minimum: min, maximum: max }
|
12 | : { exclusiveMinimum: min, exclusiveMaximum: max };
|
13 | },
|
14 | metaSchema: {
|
15 | type: "array",
|
16 | minItems: 2,
|
17 | maxItems: 2,
|
18 | items: { type: "number" },
|
19 | },
|
20 | });
|
21 | function validateRangeSchema(min, max) {
|
22 | if (min > max || (keyword === "exclusiveRange" && min === max)) {
|
23 | throw new Error("There are no numbers in range");
|
24 | }
|
25 | }
|
26 | }
|
27 | exports.default = getRangeDef;
|
28 |
|
\ | No newline at end of file |