ruuda / rcl

A reasonable configuration language
https://rcl-lang.org
Apache License 2.0
197 stars 8 forks source link

[ feature request ] schema #60

Open yonas opened 3 months ago

yonas commented 3 months ago

RCL is awesome. I'd like to be able to specify a schema to validate an RCL file.

I could output to JSON and write a separate JSON Schema. If RCL supported JSON Schema, I would be saved from using another tool.

If RCL has it's own schema language, that would work too.

denfren commented 3 months ago

Sounds the like planned record types feature will help with that.

Once you have that type you could do

let out: TYPE_HERE = { ... };
out
ruuda commented 3 months ago

Yep, this is exactly the idea behind the type system! It will not map 1:1 to JSON Schema, but you will be able to enforce similar things with it. The way I imagine it’s most useful is not just to validate that a value matches a schema all the way at the top level, but also to annotate intermediate values to catch errors early.

This will take some more work, I’ll keep this issue open until record types are implemented.