Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
Once i/o boundaries are parsing unknown types into static types, your type safety is guaranteed.
[0] https://github.com/appliedblockchain/assert-combinators
This is not yet possible in Typescript, but imagine if you could define a numerical subtype that requires your input be below some threshold eg:
`type Limit = 0..100;`
See discussion here: https://github.com/Microsoft/TypeScript/issues/15480
Not exactly what you want, I think, but there is zod [0].
I really would like to see nominal typing support in TypeScript. Currently, it's hard to validate a piece of data (or parse for that matter) once and have other functions only operate on that validated data. There are (ugly?) workarounds though [1].
[0]: https://github.com/colinhacks/zod
It doesn't use json schema, but you might be interested in something like this: https://gcanti.github.io/io-ts/
Well, it's a minimal framework. Parsers are supposed to implement a particular function definition [1] and use the "Parsed" type for their return value, which if widely adopted, will result in references to the core library's types appearing in a lot of API's.
The advantage is that you can write code using generics that works with any parser, but I'm a little skeptical about the value of generic code.
[1] https://github.com/parsix/parsix#build-your-own-parse
Related posts
- Displaying multiple error messages on incorrect form entries with Vee-validate | Vue
- Popular Libraries For Building Type-safe Web Application APIs
- Leaving LinkedIn: Choosing Engineering Excellence over Expediency
- Mastering Type-Safe JSON Serialization in TypeScript
- [DDD] Tactical Design Patterns Part 3: Presentation/Infrastructure Layer