class-transformer
Superstruct
Our great sponsors
class-transformer | Superstruct | |
---|---|---|
24 | 25 | |
6,456 | 6,787 | |
1.3% | - | |
6.9 | 5.7 | |
about 1 month ago | 17 days ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
class-transformer
-
[Nestia] Boost up your NestJS server much faster and easier (maximum 20,000x faster)
JSON serialization is 200x faster than class-transformer
-
How can I declare, integrate a JSON (or similar type that is supposed to be data sent from a server) file into my Angular app, and use it;s data to display the array of Devices within it?
Also OP can check out class-transformer + class-validator if he want to properly instantiate objects and validate them with precise and verbose output of potential format errors. OP can even go the god tier way by setting up a custom RxJS operator that does that for him easily.
-
NestJS GraphQL image upload into a S3 bucket
Start by installing the class-transformer and class-validator packages for dto validation (see more in the docs), sharp for image optimization, and the S3 client packages.
-
Fixing a Promise return object to be typed in Typescript
View on GitHub
- Why doesn’t TypeScript natively do any type checking
-
class-transformer VS TypeManager.TS - a user suggested alternative
2 projects | 22 May 2022
-
Rewrite Dynamic form group builder for Angular13+
To implement new features, the original class-transformer had to be abandoned, since it does not publish the meta date that it collects. Fork that publishes metadata to the global - https://github.com/petrzjunior/class-transformer (PR: https://github.com/typestack/class-transformer/pull/929)
-
How to properly sanitise & check POST data from REST API? Which libraries can you suggest? best ways nowadays in 2022
I really enjoyed using class-transformer and class-validator for this.
-
How do you "stitch & glue" types for all your needs?
The class-validator / class-transform looks really nice for formatting/validation but there is also joi. suretype is attractive since theoretically typeconv could generate jsonSchema for json-schema-faker and Open API docs.
- Handling json input in an express app
Superstruct
-
Lessons from open-source: Replace zod with superstruct if you do not use zod’s advanced capabilities
This is where I saw compiled folder has superstruct’s minified code.
-
Mastering Type-Safe JSON Serialization in TypeScript
However, working with the unknown type is less convenient than merely specifying the desired data type. Apart from type-casting, there are multiple ways to convert the unknown type into the required data type. One such method is utilizing the Superstruct library to validate data at runtime and throw detailed errors if the data is invalid.
- Where DRY Applies
-
Unleashing the Power of TypeScript: Improving Standard Library Types
For example, the superstruct library is a lighter alternative to Zod. This library is more suitable for use on the client side since it has a relatively small size (13.1 kB vs 3.4 kB).
-
Banditypes: The mighty 400-byte schema validator for TS / JS
Banditstash, like all the newer validation libraries (yup, zod, superstruct, typed) can auto-generate TS type from a JS schema:
-
Typescript Runtime Validators and DX, a type-checking performance analysis of zod/superstruct/yup/typebox
Superstruct 1.0.3
-
React Router Actions Form Submission and Validation
Inside the action, the first thing we're going to do is get the formData using the request object. Then we will create an object from the formData data that will later be validated by our superstruct schema.
-
Is there any reason not to use typescript?
You could use Zod or Superstruct to validate the types of values, or use typestack/class-validator if it makes sense.
- Why doesn’t TypeScript natively do any type checking
-
Build end-to-end typesafe APIs with tRPC
tRPC is a built on top of react-query, which is a package for fetching, caching, and updating data without the need of any global state. We are also using zod for schema and input validations. You can also use other validation libraries like yup, Superstruct, etc. Read more.
What are some alternatives?
zod - TypeScript-first schema validation with static type inference
TypeORM - ORM for TypeScript and JavaScript. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Yup - Dead simple Object schema validation
class-validator - Decorator-based property validation for classes.
joi - The most powerful data validation library for JS [Moved to: https://github.com/hapijs/joi]
ajv - The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
typescript-is
typebox - Json Schema Type Builder with Static Type Resolution for TypeScript
MikroORM - TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
openapi-cop - A proxy that validates responses and requests against an OpenAPI document. https://www.npmjs.com/package/openapi-cop https://hub.docker.com/r/lxlu/openapi-cop