Skip to content

Commit

Permalink
fix tracking unevaluatedProperties for always valid patterns in patte…
Browse files Browse the repository at this point in the history
…rnProperties
  • Loading branch information
epoberezkin committed Jun 6, 2021
1 parent 3e285b0 commit 795a8f8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/vocabularies/applicator/patternProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ const def: CodeKeywordDefinition = {
const {gen, schema, data, parentSchema, it} = cxt
const {opts} = it
const patterns = allSchemaProperties(schema)
const validPatterns = patterns.filter((p) => !alwaysValidSchema(it, schema[p] as AnySchema))
const checkForUnevaluatedProperties =
parentSchema.unevaluatedProperties !== true &&
parentSchema.unevaluatedProperties !== undefined
const alwaysValidPatterns = patterns.filter((p) =>
alwaysValidSchema(it, schema[p] as AnySchema)
)

if (patterns.length === 0 && (validPatterns.length === 0 || !checkForUnevaluatedProperties)) {
if (
patterns.length === 0 ||
(alwaysValidPatterns.length === patterns.length &&
(!it.opts.unevaluated || it.props === true))
) {
return
}

Expand Down Expand Up @@ -59,7 +62,7 @@ const def: CodeKeywordDefinition = {
function validateProperties(pat: string): void {
gen.forIn("key", data, (key) => {
gen.if(_`${usePattern(cxt, pat)}.test(${key})`, () => {
const alwaysValid = !validPatterns.includes(pat)
const alwaysValid = alwaysValidPatterns.includes(pat)
if (!alwaysValid) {
cxt.subschema(
{
Expand Down

0 comments on commit 795a8f8

Please sign in to comment.