-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add method for injecting defaults #76
Comments
|
Yes, validation fails at least at https://www.jsonschemavalidator.net/ |
Would you not run setDefaults before validate? Also, should you not validate against the previous version of the schema anyway? |
This would be a good idea to call it before, but this is up to consumer. Question here: should cases like |
At least a warning is warranted. Something like "WARN required AND default found for field x! Required is redundant!". An error is also an option if that definition will cause errors. The warning will alert the user to a possible omission, but the execution is possibly unaffected by removing required in the case that default is present. Either way is fine as the user needs to know that this is pointless. |
Yep. This is exactly how all linters work. If it sees |
I'm thinking this can be a separate enrichment. |
Following instance:
Is valid against following schema:
Though
.validate
method won't inject default value forbar
. And I believe this is correct behavior. Instead we should have method like.setDefaults
that when invoked mutates original JSON by setting missingbar
(but notfoo
of course)./cc @knservis
The text was updated successfully, but these errors were encountered: