11 ms·
I think the author knew this but wanted a more minimal type of validation.
by eventreduce 6y ago
I think the author knew this but wanted a more minimal type of validation.
- arethuza 6y agoJson schema does scale down pretty well (indeed as the link above shows the simplest possible Json schema is just "{}") - it also has pretty good tool support (e.g. VS Code) - there is a Json schema for Json schemas which helps a lot. 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.
- eventreduce 6y agoJson-schema itself scales down pretty well. But the libraries for validating it do not. Even if your schema is only {}, the build size increment because of pulling in a jsonschema validator is enormous because of all these supported features.
- arethuza 6y agoFair enough I guess - don't think I've ever had a need to do client side JSON validation against a 'schema' so I've never had that concern.
- xg15 6y ago> Json schema does scale down pretty well (indeed as the link above shows the simplest possible Json schema is just "{}") 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)