Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duplojs/zod-accelerator
https://github.com/duplojs/zod-accelerator
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/duplojs/zod-accelerator
- Owner: duplojs
- Created: 2024-03-06T13:41:13.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-09T12:49:19.000Z (3 months ago)
- Last Synced: 2024-09-09T14:57:24.556Z (3 months ago)
- Language: TypeScript
- Size: 854 KB
- Stars: 27
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome - duplojs/zod-accelerator - (TypeScript)
README
# zod-accelerator
[![NPM version](https://img.shields.io/npm/v/@duplojs/zod-accelerator)](https://www.npmjs.com/package/@duplojs/zod-accelerator)## Instalation
```
npm i @duplojs/zod-accelerator
```## Benchmarck
![Benchmarck result](/benchmarck-result.png)## Utilisation
```ts
import * as zod from "zod";
import {ZodAccelerator} from "@duplojs/zod-accelerator";const zodSchema = zod.object({
firstname: zod.string(),
lastname: zod.string(),
age: zod.number(),
email: zod.string(),
gender: zod.enum(["boy", "girl"]),
connected: zod.boolean(),
createdAt: zod.date(),
addresse: zod.object({
postCode: zod.string(),
city: zod.string(),
number: zod.number()
}),
}).array();const zodAccelerateSchema = ZodAccelerator.build(zodSchema);
const inputData = Array.from({length: 10}).fill({
firstname: " Mike ",
lastname: "ee",
age: 21,
email: "[email protected]",
gender: "girl",
connected: true,
createdAt: new Date(),
addresse: {
postCode: "22778",
city: "Paris",
number: 67
},
});const outputData = zodAccelerateSchema.parse(inputData);
```