I kinda miss the blog era and seeing all your posts makes me feel like I want to participate too. So there is a fresh blog post about Input validation, JSON Schema, and a library I wrote to work with that.
I cross my fingers I will find the time to write more, it’s cool but also kinda time consuming
IMO a nod to other state of the art like Cue would have made the post even more valuable – but maybe you don’t want it too widely scoped which would be fair.
Since I read “Parse, don’t validate” by Lexi King, I became the evangelist of this approach. That’s why estructura allows JSONSchema as a—well—schema, but it still goes through parsing anyway.
Yes at some point I started a Cue pet project in Elixir (and Dhall, and Nix-lang … I love writing parsers) but they are not as widepsread yet. The post is already drifting from personal to spec generalities to implementation examples, I wanted to keep it short indeed.
I’m not sure if it is obvious in the post but the JSV.validate functions family does cast data to expected data structures (post has examples with Date struct and custom struct). What I did not implement is coercion though, because JSON does not need it in general so it’s better to not have unexpected valid values (the real reason being that it’s not in the spec). Coercion seems more useful when you have looser specs like YAML where strings do not need quotes, then the schema should define in 123 is a number or a string.