Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Track evaluated properties with pattern properties of schema = true #1626

Merged
merged 1 commit into from
Jun 6, 2021
Merged

Track evaluated properties with pattern properties of schema = true #1626

merged 1 commit into from
Jun 6, 2021

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented May 25, 2021

What issue does this pull request resolve?

#1625

What changes did you make?

patternProperties that are always valid are tracked now to ensure unevaluatedProperties keyword 'works'.

Is there anything that requires more attention while reviewing?

checkForUnevaluatedProperties check?

@epoberezkin
Copy link
Member

I will update it

@epoberezkin epoberezkin merged commit 3e285b0 into ajv-validator:master Jun 6, 2021
@epoberezkin
Copy link
Member

epoberezkin commented Jun 6, 2021

@P0lip the updated condition to bypass validation is:

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

to spell it, we want to skip validation in one of two cases:

  • there are no patterns in the schema at all
  • all patterns have always valid schemas AND we either do not track unevaluated properties (!it.opts.unevaluated) or all properties are already evaluated (it.props === true)

Does it make sense?

@P0lip
Copy link
Contributor Author

P0lip commented Jun 7, 2021

Yup, make sense,
Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants