main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
869 bytes
|
Rev | Line | |
---|
[79a0317] | 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 | //# sourceMappingURL=_range.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.