1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- function addKeyword(ajv, keyword, definition) {
- let customRuleCode;
- try {
-
-
- customRuleCode = require("ajv/lib/dotjs/custom");
- const {
- RULES
- } = ajv;
- let ruleGroup;
- for (let i = 0; i < RULES.length; i++) {
- const rg = RULES[i];
- if (typeof rg.type === "undefined") {
- ruleGroup = rg;
- break;
- }
- }
- const rule = {
- keyword,
- definition,
- custom: true,
- code: customRuleCode,
- implements: definition.implements
- };
- ruleGroup.rules.unshift(rule);
- RULES.custom[keyword] = rule;
- RULES.keywords[keyword] = true;
- RULES.all[keyword] = true;
- } catch (e) {
- }
- }
- function addUndefinedAsNullKeyword(ajv) {
-
- addKeyword(ajv, "undefinedAsNull", {
- modifying: true,
-
- validate(kwVal, data, parentSchema, dataPath, parentData, parentDataProperty) {
- if (kwVal && parentSchema && typeof parentSchema.enum !== "undefined" && parentData && typeof parentDataProperty === "number") {
- const idx =
-
- parentDataProperty;
- const parentDataRef =
-
- parentData;
- if (typeof parentDataRef[idx] === "undefined") {
- parentDataRef[idx] = null;
- }
- }
- return true;
- }
- });
- return ajv;
- }
- var _default = addUndefinedAsNullKeyword;
- exports.default = _default;
|