Comparing version 5.2.9-skhema-enum-failure-19a97f9bcf56abdff86747e18731da2f7161d1bf to 5.2.9-skhema-enum-failure-4ff1988ca8c78192ad0f92afb7f2bb3d2679fdd2
@@ -7,4 +7,5 @@ # Change Log | ||
## 5.2.9 - 2019-12-02 | ||
## 5.2.9 - 2019-12-05 | ||
* When combining with baseSchema merge enum with AND operator [StefKors] | ||
* Add test to show .filter() not working correctly [StefKors] | ||
@@ -11,0 +12,0 @@ |
@@ -1247,2 +1247,29 @@ /* | ||
// When combining with the baseSchema | ||
// the enum values need to be merged together with an AND operator | ||
// to do this we recreate the subschema to use allOf | ||
if (sourceValue && objectValue && sourceValue.enum && objectValue.enum) { | ||
const { | ||
enum: enumObject, ...restObject | ||
} = objectValue | ||
const { | ||
enum: enumSource, ...restSource | ||
} = sourceValue | ||
const newObject = merge(restSource, restObject) | ||
if (!newObject.allOf) { | ||
newObject.allOf = [] | ||
} | ||
newObject.allOf.push({ | ||
enum: enumObject | ||
}, { | ||
enum: enumSource | ||
}) | ||
return newObject | ||
} | ||
if (key === 'enum') { | ||
@@ -1249,0 +1276,0 @@ return uniq(sourceValue) |
{ | ||
"name": "skhema", | ||
"version": "5.2.9-skhema-enum-failure-19a97f9bcf56abdff86747e18731da2f7161d1bf", | ||
"version": "5.2.9-skhema-enum-failure-4ff1988ca8c78192ad0f92afb7f2bb3d2679fdd2", | ||
"description": "JSON Schema utility collection", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1048,3 +1048,3 @@ /* | ||
// Comment | ||
const element = { | ||
const object = { | ||
id: 'ccdca138-e686-486c-a5df-6661be1102a9', | ||
@@ -1095,4 +1095,3 @@ slug: 'support-thread-test-thread-10eb964c-70e6-4a50-a0d6-364111416cdd', | ||
const result = skhema.filter(schema, element) | ||
const result = skhema.filter(schema, object) | ||
test.deepEqual(result, null) | ||
@@ -1099,0 +1098,0 @@ }) |
145137
5193