Skip to content

Include schema validation code (and print nice errors if KDL doesn't follow the schema) #116

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

Open
TheLostLambda opened this issue Jan 19, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@TheLostLambda
Copy link

I'm still working on #83, but it's occurred to me that, whilst having serde support for simple config and data files is ideal, I'm actually using kdl to write more complex configuration files with logic that means things like the order of children is sometimes important. For that, it's likely easiest for me just to work my way through the KDL AST, but the reason I've been using knuffel / knus in the past is because I think it's really valuable to have a schema that's self-documenting in code like that. If you want to know which KDL is legal for a configuration file, a couple of lightly annotated structs tell you everything you need to know!

Now, I've since realized that there is a KDL schema language (which seems perfect for this — run a validate_schema function, get nice user errors, I get to have my single-source-of-truth in the schema file, and then I can use the AST directly and not worry about doing any "syntax" validation for my KDL file format), but I can't currently find any tools that actually check a KDL file against a schema in this crate?

It's very possible I'm just missing something, but if not, this is another thing I'd love to add, and I think it would address ¾-ths of whats needed for #76

@zkat zkat added the enhancement New feature or request label Jan 19, 2025
@zkat zkat self-assigned this Jan 19, 2025
@zkat
Copy link
Member

zkat commented Jan 19, 2025

I'm actually working on the new schema format, and I plan on writing a schema verifier into this repo once that's done (and including it with kdl-lsp). You can see the WIP schema work over at https://github.com/kdl-org/kdl/pull/486/files

@TheLostLambda
Copy link
Author

@zkat That's super exciting! Okay, I'll leave you to it and am happy to provide feedback if you're ever wanting anyone to kick the tires! In the meantime I'll focus on serde a la quick-xml!

@zkat
Copy link
Member

zkat commented Jan 19, 2025

Absolutely interested in feedback about how it looks so far. I'm still iterating on it but I would like to know if it feels like the right direction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants