I like how compact it turned out: https://github.com/healthchecks/healthchecks/blob/master/hc/...
Usage examples in tests: https://github.com/healthchecks/healthchecks/blob/master/hc/...
The main advantage of the approach in the article appears to be that its easy to extend validation with code - which is a nice touch. Pretty much any complex Json validation I have written has to combine both schema based validation and code based checks - usually done completely separately.
I've not used JSON Schema so far, but I think showing the simplest possible definition does not tell much about how complex or easy to use a language is.
E.g., it's easy to write C code for a working program that does nothing or just prints "Hello World". The resulting code is very simple and can be written without much experience in C.
However that doesn't make C a simple language - and indeed writing programs in C that perform useful tasks is a lot more complex and requires more knowledge about the language.
In the same way, it's nice that Json Schema has a compact syntax for the "do nothing" schema, but I think a comparison between practically used examples would be better.
(Also the "do nothing" schema would have to compare against not doing schema validation at all - and compared to that, even the two brackets are still pretty costly)
import ok from 'json-ok';
ok(24, { type: "number" });
// No issue
ok(24, { type: "string" });
// throws ValidationError: is not of a type(s) string
I wanted to use `ok-json` as a tongue-in-cheek name, but apparently since there is already a library called `okjson` npm didn't allow me to use it.