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

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.0 KB
Line 
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 *
14 * @param {Ajv} ajv
15 * @returns {Ajv}
16 */
17function addUndefinedAsNullKeyword(ajv) {
18 ajv.addKeyword({
19 keyword: "undefinedAsNull",
20 before: "enum",
21 modifying: true,
22 /** @type {SchemaValidateFunction} */
23 validate(kwVal, data, metadata, dataCxt) {
24 if (kwVal && dataCxt && metadata && typeof metadata.enum !== "undefined") {
25 const idx = dataCxt.parentDataProperty;
26 if (typeof dataCxt.parentData[idx] === "undefined") {
27 // eslint-disable-next-line no-param-reassign
28 dataCxt.parentData[dataCxt.parentDataProperty] = null;
29 }
30 }
31 return true;
32 }
33 });
34 return ajv;
35}
36var _default = exports.default = addUndefinedAsNullKeyword;
Note: See TracBrowser for help on using the repository browser.