source: frontend/node_modules/schema-utils/dist/keywords/undefinedAsNull.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[9af201e]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7/** @typedef {import("ajv").default} Ajv */
8/** @typedef {import("ajv").SchemaValidateFunction} SchemaValidateFunction */
9/** @typedef {import("ajv").AnySchemaObject} AnySchemaObject */
10/** @typedef {import("ajv").ValidateFunction} ValidateFunction */
11
12/**
13 * @param {Ajv} ajv ajv
14 * @returns {Ajv} configured ajv
15 */
16function addUndefinedAsNullKeyword(ajv) {
17 ajv.addKeyword({
18 keyword: "undefinedAsNull",
19 before: "enum",
20 modifying: true,
21 /** @type {SchemaValidateFunction} */
22 validate(kwVal, data, metadata, dataCxt) {
23 if (kwVal && dataCxt && metadata && typeof metadata.enum !== "undefined") {
24 const idx = dataCxt.parentDataProperty;
25 if (typeof dataCxt.parentData[idx] === "undefined") {
26 dataCxt.parentData[dataCxt.parentDataProperty] = null;
27 }
28 }
29 return true;
30 }
31 });
32 return ajv;
33}
34var _default = exports.default = addUndefinedAsNullKeyword;
Note: See TracBrowser for help on using the repository browser.