https://github.com/stefanterdell/zonk
Zod-validated proxies
https://github.com/stefanterdell/zonk
Last synced: 3 months ago
JSON representation
Zod-validated proxies
- Host: GitHub
- URL: https://github.com/stefanterdell/zonk
- Owner: StefanTerdell
- Created: 2023-05-17T22:00:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-17T22:05:51.000Z (over 2 years ago)
- Last Synced: 2025-07-04T10:37:44.267Z (3 months ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# zonk
Because Zod + Stronk = Zonk 💪
## Usage
Zonk creates ~~strongly typed~~ _strongly opinionated_ objects and arrays from your existing [Zod-schemas](https://www.github.com/colinhacks/zod).
Importing zonk extends your Zod object- and array schemas with the `.zonk()` method, which you can call with a valid input. You then receive a proxy that validates any changes to its children, ie. any mutation causes the schema to validate itself and its children.
## Example
```ts
import { z } from "zod";
import "zonk";const zSchema = z.object({ arr: z.array(z.number()) });
const value = zSchema.zonk({ arr: [1, 2, 3] });
value.arr.push("This will throw an error 💥" as any);
```## Plans
This was just an intrusive thought that needed to be toyed with for a couple of hours. I have no idea if it will go any further than that.