5

Typed: A 1kb type-safe runtime validation library

 2 years ago
source link: https://dev.to/brielov/typed-a-1kb-type-safe-runtime-validation-library-5end
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Cover image for Typed: A 1kb type-safe runtime validation library

Typed: A 1kb type-safe runtime validation library

I've been working on a little side project which I ultimate decide to make public so that somebody else can maybe benefit from it on their own projects. typed is similar to superstruct and zod in that it validates data at runtime and it's type-safe but what's different about it is that it comes in a tiny package (1kb) with an ESM build and it also outperforms them by a significant amount. If you're curious about it you can check it out on GitHub or NPM.

GitHub logo brielov / typed

Smallest runtime type-checking library ever made

Typed

A blazing fast, dependency free, 1kb runtime type-checking library written entirely in typescript, meant to be used with it.

There are dozens of validation libraries out there, so why create yet another one? Well, I tried almost every library out there and there is only one that I really like called superstruct (which is awesome) that provides almost everything that I want, but still, I wanted to create my own. The others are simply bloated or don't provide proper typescript support. So that's where typed comes in.

typed is all about function composition. Each function is "standalone" and provides a safe way to validate data, you don't need a special kind of function to execute a schema against some value. All functions return a special type which is either Success<T> or Failure. If success is true then value is available and fully typed and if not, errors is…


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK