anweiss / cddl

Concise data definition language (RFC 8610) implementation and JSON and CBOR validator in Rust
https://cddl.anweiss.tech
MIT License
90 stars 12 forks source link

wishlist: Simplify creation of new validators #225

Open chrysn opened 3 months ago

chrysn commented 3 months ago

Currently, the validators for JSON and CBOR contain a mix of serialization-specific code and CDDL tracking (which AIU includes much of the error handling), as evidenced by the large similarity between src/validator/{cbor,json}.rs. This makes it hard to add another validator, in my case, one that processes CBOR diagnostic notation (where the goal is to leave information in the tree that is being visited, eg. spelling out numeric keys with comments or picking <<1>> instead of h'01' when seeing a .cbor).

Hoisting out commonalities from those two files might also help with #219.