-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fully validate given config on construction #49
Comments
Sorry, I'm not quite following this (probably so much multitasking). Re "automatically generate the prototype config" perhaps the template generation capability could help (at least in part)? Re "it will error out on the first one" ... you are suggesting to use checkValid to report all possible missing/invalid entries at once? If so, I'm afraid it'd be more complicated than that... Surely I'm not really understanding your observation/suggestion. |
The issue with just calling the Instead, you can call |
Thanks for the extra clarification. |
"Fully validate given config on construction"
Hi @abonander I already did good progress on a complete validation of the input config (thanks again for the great suggestion), but won't be able to give this some more exhaustive testing for a while. As previously noted, this validation requires some more logic than a mere checkValid mainly due to the possibility of having optional entries (even complete subtrees in the config), so such validation has to take that into account. My focus has initially been on collecting/reporting all "missing" (required) properties, but later on this should also consider collecting all incompatible values. The code is in the 49_full_validation branch if you have some time to give it a try. |
@abonander fyi just released 0.9.92 with this. |
Looking through the codegen it appears that it just calls
Config.get*()
for each of the config object's fields, so if any keys are missing or mistyped it will error out on the first one.However, you can call
Config.checkValid()
with a prototype config and it will report errors for all missing or mistyped keys in the config with a runtime exception; we've been specifying a schema manually in our config static class (which kind of invalidates my point in #47 about not having two different sources of truth for the config schema but this way we would still only have a single spec, our default config) but it would be nice when using this library to automatically generate the prototype config and validate the config being passed to the constructor, e.g. for the example in README:The text was updated successfully, but these errors were encountered: