3 ms·
I too used JSON Schema until it grated on me enough to finally abandon it... But I haven't taken the leap into TypeScript yet. Lately I've been specifying schem
by dandelany 10y ago
I too used JSON Schema until it grated on me enough to finally abandon it... But I haven't taken the leap into TypeScript yet. Lately I've been specifying schemas with Tcomb[0], which I quite like. It's different from JSON Schema in that it's code and does runtime checking, so it's not a fit for every project. But it's pretty trivial to write a little node-based Tcomb validator if you want to be able to validate from a CLI. It's quite simple, but expressive, and I find that the fact that it's code can be a benefit, since it's simpler to compose complex schemas with code. As a bonus (or downside, depending on your use case), you also get pseudo-immutability on your Tcomb structs for free.
[0] https://github.com/gcanti/tcomb https://github.com/gcanti/tcomb