Skip to content
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

Improve handling of schema defaults #71

Open
nbgl opened this issue Mar 20, 2018 · 0 comments
Open

Improve handling of schema defaults #71

nbgl opened this issue Mar 20, 2018 · 0 comments

Comments

@nbgl
Copy link
Contributor

nbgl commented Mar 20, 2018

Currently, the defaults are embedded in the code. This is in addition to them being listed in the master schema. This can lead to inconsistencies if the defaults are changed in one place but not the other. It can also be the cause of bugs. It would be nice to have one place for storing all the defaults, or at least a way to ensure that all the defaults match.

One idea is to have JsonSchema populate objects' defaults from the schema. This is something it doesn't do by default, but is capable of doing with minor hacking. See their documentation. They say, … none of the other validators modify the instance either. … It’s perfectly valid (and perhaps even useful) to have a default that is not valid under the schema it lives in! So an instance modified by the default would pass validation the first time, but fail the second! Still, this would be more elegant than the current solution.

Another solution may be to write a test that reads both sets of defaults and compares them. It would fail if anything is changed in only one place. However, it would require maintenance if ever we add any more defaults.

Aha! Link: https://csiro.aha.io/features/ANONLINK-45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant