Skip to content

Commit

Permalink
fix: improve logic and apply only for enum
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jun 7, 2023
1 parent 7c5a40e commit 10443c3
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 18 deletions.
7 changes: 6 additions & 1 deletion src/keywords/undefinedAsNull.js
Expand Up @@ -15,7 +15,12 @@ function addUndefinedAsNullKeyword(ajv) {
modifying: true,
/** @type {SchemaValidateFunction} */
validate(kwVal, data, metadata, dataCxt) {
if (kwVal && dataCxt) {
if (
kwVal &&
dataCxt &&
metadata &&
typeof metadata.enum !== "undefined"
) {
const idx = dataCxt.parentDataProperty;

if (typeof dataCxt.parentData[idx] === "undefined") {
Expand Down

0 comments on commit 10443c3

Please sign in to comment.