-
Notifications
You must be signed in to change notification settings - Fork 106
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
Configuration File Schema Validation #281
Comments
This would be useful - would have saved me some time yesterday! |
I might take a look at this later. @NuSkooler How do you see it working? A separate tool to begin with? |
@louisnorthmore I haven't put a ton of detailed thought into this, but something like:
I like the idea of veirfy-json since it's light weight and allows custom validators. |
At this point if it hasn't been picked up yet, I change my stance and suggest JSON schema as it's been the clear winner around JSON... schemas. Upon validation error(s), writing to |
Agreed with the overall approach, and this would be fantastic. I know when I was getting started having a broken config was my biggest struggle. The only one I'm not sure about is the last bullet point: "Must allow for additional entries/sections that are not known to the schema" - this would somewhat limit some of the usefulness I think? If someone is trying to debug why a configuration item is not taking effect, etc, this would be easier if there was at least the option to restrict to known elements. |
@cognitivegears I think we can validate things that are in the wrong place, and specifics of all known configuration elements, but consider e.g. a custom mod that is not shipped with enig, but wants some configuration from In JSON schema at least, this probably mostly around allowing additional properties in certain blocks. |
Well, we could validate something that is missing, but not something that is optional but misnamed. And since there are a lot of optional properties in the enigma conf I feel this could be a problem. Not the end of the world for sure, but how about a slightly different approach: Add an optional "mods" property at each level containing an array of objects of "any" type. That way, mods are free to add additional properties, they just have to put it under "mods". So like:
Since it is validated with the "any" type, it doesn't care or validate what is under the mod (if the mod wanted to validate the values itself with it's own schema it could, but doesn't have to.) Still "wild west", just a little more "wild west, but stay in your sandboxes." :) Then we could validate everything else. |
In Here is what I'm thinking (this example with
Another thing we can do, is expose some API(s) that mods can use to easily do their own validation if they want to opt-in.
|
That looks great! Sounds like a good approach to me. |
I suppose another approach for |
Yeah I really like that approach for the main config. This sounds super interesting hope we can do this soon |
It may be nice to have very basic schema validation for configuration files (
config.hjson
,menu.hjson
, etc.).Configuration files are in HJSON, but this directly converts to JSON internally. It may be enough to work with the JSON.
JSON schema validation resources:
See also: #280
The text was updated successfully, but these errors were encountered: