-
-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useDefaults doesn't work with conditional requires #2456
Comments
I need to look into it more but given that This page explains the uncertainties when dealing with schemas that both modify and validate the data. With that being said, this may be a bug and may be fixable, so I will try and get my head around it. |
Super nice, appreciate it. We have been running 6.12.6 for some time now and want to migrate to version 8, but this breaking behaviour is currently blocking the upgrade. Thanks! |
After looking into this and discussing with @epoberezkin this will be a "nofix" unfortunately. If you look at the big red warning on this page you'll see that order of evaluation, which may possibly be the thing that changed between version 6 and 8 to make this start failing for you, is not something we can guarantee or document. This is the sort of problem you will always run into when you expect a single declarative schema to do imperative operations (such as "set defaults" followed by "validate the data"). Normally the best suggestion if you want to guarantee order of operations is to use |
What version of Ajv are you using? Does the issue happen if you use the latest version?
8.16.0 - yes
Ajv options object
JSON Schema
Sample data
Your code
https://runkit.com/timberbain/6671765baad1af0008237f25
Validation result, data AFTER validation, error messages
What results did you expect?
I expected no validation errors as useInterconnect has been defaulted to false.
Previously running the same code with version 6.12.6 (without the strict option as it was introduced in later version) the schema is considered valid. But after migrating to version 8.16.0, the data is no longer valid according to the schema.
The text was updated successfully, but these errors were encountered: