Currently, if a field in the Json is missing or wrongly typed, the resulting error is just a mess.
Research
There are a few possible solutions to this problem:
Using JSON Schema
π JSON is well known
β Syntax is overly complicated
β assumes that all fields are optional - This misses the point a bit.
Using a type checking libary for JS called typy
π Everyone knows how to write JS, so writing your own validator would not be hard.
β Could be used to inject unwanted code
Using the configuration language jsonnet instead of JSON.
β Can't actually validate, but provide default values. This can indirectly solve the problem.
π Extendable to also include preprocessing
β jsonnet is not very well known
Using the configuration language CUE
π simple to write validator
π Can be extended to a preprocessor
β No native Node.js (would need async calls to access it)
β No VS Code support
Using Joi Schemas to validate the json
π simple to write validator
π syntax is basic
β outdated. Seems like a hobby project
Currently, if a field in the Json is missing or wrongly typed, the resulting error is just a mess.
Research
There are a few possible solutions to this problem: