3 ms·
There’s a lot of compelling reasons to share code particularly at network boundaries. Using something like io-ts/zod/etc gives you simple, declarative, type saf
by eyelidlessness 6y ago
There’s a lot of compelling reasons to share code particularly at network boundaries. Using something like io-ts/zod/etc gives you simple, declarative, type safe validation. Being able to share that behavior is an enormous productivity boost in and of itself.
- twic 6y agoSharing validation for forms is definitely really nice. It feels like it should be possible to do that cross-language, generating some JS validation rules from Java annotations, say, but i have never seen it done.
- eyelidlessness 6y agoThe way it’s usually done is with a generalized language-agnostic spec like OpenAPI/JSON Schema. Because the definitions are standardized, you can effectively build tools in any language that should provide the same validation, to the extent they’re compliant and the spec is unambiguous. These approaches can of course be combined, where the sorts of validators I mentioned generate (or even build their primitives around) those more verbose standards.