Comparing version 5.2.10-faulty-anyof-bug-c5b947d371954d36873cc920fa3ab3b07fe7ad38 to 5.2.10
@@ -10,3 +10,3 @@ # Change Log | ||
* Fix bug where anyOf is matched incorrectly [Lucian Buzzo] | ||
* .filter(): Only match if the base schema matches [Lucian Buzzo] | ||
@@ -13,0 +13,0 @@ ## 5.2.9 - 2019-12-05 |
@@ -881,3 +881,3 @@ /* | ||
// Create an instance of AJV that will be used to perform simple matchin | ||
// Create an instance of AJV that will be used to perform simple matching | ||
const matchAjv = new AJV({ | ||
@@ -943,22 +943,29 @@ allErrors: true, | ||
for (const item of items) { | ||
const matchers = collectMatchers(item, fragmentValidators) | ||
const baseValidator = matchAjv.compile( | ||
allowAdditionalProperties(clone(baseSchema)) | ||
) | ||
// If no branches match we return the main schema validator | ||
if (matchers.length === 0) { | ||
if (filterValidator(item)) { | ||
result.push(item) | ||
} | ||
} else { | ||
// Otherwise we merge the branch fragments together to create a new filterValidator | ||
const filterSchema = makeFilter(baseSchema, matchers) | ||
// Only continue if the base schema matches | ||
if (baseValidator(item)) { | ||
const matchers = collectMatchers(item, fragmentValidators) | ||
// Check if there are still `anyOf` branches to resolve | ||
if (filterSchema.anyOf) { | ||
return parse(filterSchema) | ||
} | ||
// If no branches match we return the main schema validator | ||
if (matchers.length === 0) { | ||
if (filterValidator(item)) { | ||
result.push(item) | ||
} | ||
} else { | ||
// Otherwise we merge the branch fragments together to create a new filterValidator | ||
const filterSchema = makeFilter(baseSchema, matchers) | ||
const mergedFilterValidator = filterAjv.compile(filterSchema) | ||
// Check if there are still `anyOf` branches to resolve | ||
if (filterSchema.anyOf) { | ||
return parse(filterSchema) | ||
} | ||
if (mergedFilterValidator(item)) { | ||
result.push(item) | ||
const mergedFilterValidator = filterAjv.compile(filterSchema) | ||
if (mergedFilterValidator(item)) { | ||
result.push(item) | ||
} | ||
} | ||
@@ -965,0 +972,0 @@ } |
{ | ||
"name": "skhema", | ||
"version": "5.2.10-faulty-anyof-bug-c5b947d371954d36873cc920fa3ab3b07fe7ad38", | ||
"version": "5.2.10", | ||
"description": "JSON Schema utility collection", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
145838
5225
0