-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
additionalProperties considers properties with "undefined" value as additional #1240
Comments
This is related to several other issues - ajv behaviour was not specified for "undefined" properties, what is worse it is not consistent across all keywords. I think it is dangerous to change the current behaviour without the major version change, that with a bit of luck may happen this year, and they should not be addressed in isolation, the behaviour for |
There are at least 4 possible approaches, in general, each has pros / cons:
|
I think that considering them as present by default with the option to consider them as absent is the best option, for several reasons:
With this approach, by default all type-specific keywords that validate values would ignore such properties, keywords that validate keys presence would account for them, and what type keyword should do is yet another question... |
Hi @epoberezkin But I wonder - why do you think there is a good case for distinguishing the two cases in javascript? There is hardly any check that can differentiate between these cases other than This is just my 2cents - would be great to hear yours. |
related to #937 |
I just ran into this issue four years later, running ajv |
What version of Ajv are you using? Does the issue happen if you use the latest version?
6.10.2
Ajv options object
JSON Schema
Sample data
The input is not a json but a javascript object with a key set to undefined, which is common when constructing objects with conditional fields:
Your code
Validation result, data AFTER validation, error messages
What results did you expect?
I was expecting keys which are undefined to be ignored by
additionalProperties: false
Are you going to resolve the issue?
The text was updated successfully, but these errors were encountered: