Hello, I'm developer of typescript-json and have measure a benchmark comparing performance with other competitive libraries. By the benchmark, my l...
For further actions, you may consider blocking this person and/or reporting abuse
Suretype is an excellent library that folks forget to mention.
Thanks again for suggesting this library which I used in the end. Instead of deriving the validation from the types like here, they go the other way around. You define the validation rules, which can define more precise rules than mere type definitions, and it deduces the type directly. That way, you don't need the intermediate code generation step like in this article, you get more precise validation and full typing support. Truly the best of both worlds.
It's not even packaged as an NPM module? (I know it can be npm installed from GitHub directly, but that's not nice...).
deepkit.io/library/type
Interesting. I was just looking for a json/ts validation library, what a coincidence! Well, I might as well try this out. ;) By the way, as a humble developer, performance is nice but simplicity is key. Thanks for the lib.
Hmmm.... My first attempt failed.
no transform has been configured
. I guess the generation of schemas during the compilation step is missing. Btw, I'm usingwrangler
which is a toolchain of its own, so I have no idea how to incorporate the step.The
wrangler
is something likecra
orvite
? If you can configurewebpack
, then you can use thistypescript-json
following README article. If configuring customwebpack
is too hard, I recommend to usevite
instead because its configuration is the easiest one.If you wanna detailed help or guide, you also can write an issue on the repo. Then I or another developer may help you.
Wrangler should delegate to whatever is executed by package.json's build script . Usually it's either esbuild or webpack.
As I've promised, wrote an article introducing how to use
typia
inNestJS
.dev.to/samchon/nestia-boost-up-you...
Congrats!
wow! congrats!
deepkit.io/library/type
Still a long way to go 😉
I know that library and also benchmarked it. However, it requires too much compilation time and does not support any complicate type like generic. I will report bug soon.
"too much compilation time" are you transpiling code on a potato? I've had no issues whatsoever.
"complicate type like generic" I've still had no issues whatsoever.
Anyway, it's like comparing a quantum computer to a potato 🤷♂️
Written by a guy who has never had to hand validate hundreds of dependant models, discriminated types and deeply nested model heirarchies.
No, it's not "clean architecture". It's "Dunning–Kruger effect".
Well, I'm still a junior, please don't judge me, I'm still learning! Whenever I'm doing my whole entity validation with joi, zod or something else, my business logic becomes coupled to it. And when I read the clean architecture book it says, that the core entities should not directly depend on anything. But I understand it's not a law.
Can you use
typescript-json
to validate based on JSON schemas like whatajv
does?Use
TSON.application()
function. It may what you want.You should benchmark against
@sapphire/shapeshift
!Welcome your PR.
What about more advanced runtime validations, like basic regex?
github.com/samchon/typescript-json...
Is this what you want?
That looks great. if you could combine this with branded types, so instead of email: string
you would have email: Email
And an Email type that would carry the email validation rules. And has eg type string &
Brand<EmailBrand>
My dead grandma's dead dog is faster than TypeScript. low bar
What do you mean when you write, for example, typescript-json 28.579% and zod - 100%?
github.com/samchon/typescript-json...
Slowest feature as 100% and 0% means failure.
If you wanna detailed measurement, click above link. The number means that how many jobs have done in one second.
@samchon do you plan to support ts to json-schema export in this library or an extension of this library?
What about using
TSON.application()
function? It generates JSON schema.Two questions...
No plan to measure yup because it does not support even union type
No plan to make it. But welcome if you make and publish it as your own.
By the way, I made a react library which requires only TypeScript type like below. It would be published after styling, clear API designing with documentation. This may be what you want.
deepkit.io/library/type
Will it work with tRPC?
I don't know about tRPC, but it may work if calling
TSON
function is possible