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:
1.2 KB
|
Rev | Line | |
---|
[79a0317] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | const codegen_1 = require("ajv/dist/compile/codegen");
|
---|
| 4 | function getDef() {
|
---|
| 5 | return {
|
---|
| 6 | keyword: "deepRequired",
|
---|
| 7 | type: "object",
|
---|
| 8 | schemaType: "array",
|
---|
| 9 | code(ctx) {
|
---|
| 10 | const { schema, data } = ctx;
|
---|
| 11 | const props = schema.map((jp) => (0, codegen_1._) `(${getData(jp)}) === undefined`);
|
---|
| 12 | ctx.fail((0, codegen_1.or)(...props));
|
---|
| 13 | function getData(jsonPointer) {
|
---|
| 14 | if (jsonPointer === "")
|
---|
| 15 | throw new Error("empty JSON pointer not allowed");
|
---|
| 16 | const segments = jsonPointer.split("/");
|
---|
| 17 | let x = data;
|
---|
| 18 | const xs = segments.map((s, i) => i ? (x = (0, codegen_1._) `${x}${(0, codegen_1.getProperty)(unescapeJPSegment(s))}`) : x);
|
---|
| 19 | return (0, codegen_1.and)(...xs);
|
---|
| 20 | }
|
---|
| 21 | },
|
---|
| 22 | metaSchema: {
|
---|
| 23 | type: "array",
|
---|
| 24 | items: { type: "string", format: "json-pointer" },
|
---|
| 25 | },
|
---|
| 26 | };
|
---|
| 27 | }
|
---|
| 28 | exports.default = getDef;
|
---|
| 29 | function unescapeJPSegment(s) {
|
---|
| 30 | return s.replace(/~1/g, "/").replace(/~0/g, "~");
|
---|
| 31 | }
|
---|
| 32 | module.exports = getDef;
|
---|
| 33 | //# sourceMappingURL=deepRequired.js.map |
---|
Note:
See
TracBrowser
for help on using the repository browser.