# zodser

> A simple zod serialiser

Latest version **0.2.0** (published 2023-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install zodser
pnpm add zodser
yarn add zodser
bun add zodser
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2023-03-02 |
| First published | 2023-02-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 54.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Shaketbaby |
| Maintainers | shaketbaby |
| Keywords | zod, serialise, serialisation |

## Links

- npm: https://www.npmjs.com/package/zodser
- Repository: https://github.com/shaketbaby/zodser
- Issues: https://github.com/shaketbaby/zodser/issues
- npm.io page: https://npm.io/package/zodser

## Alternatives

- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads

## Recent versions

- 0.2.0 (latest) — 2023-03-02
- 0.1.2 — 2023-02-22
- 0.1.1 — 2023-02-14

## README

# zodser

A serialisation and deserialisation libarary for Zod.

This is useful when there is a need to keep a list of historic versions of zod schema.

# Install

```bash
npm install zodser
```

```bash
yarn add zodser
```

# Usages

To serialise a zod schema to a string for saving
```js
import { serialise } from "zodser";

const schemaString = serialise(zodSchema);
```

To deserialise a previously serialised zod schema string
```js
import { deserialise } from "zodser";

const zodSchema = deserialise(schemaString);
```

## limitations

Currently, all built-in Zod types except ZodEffect are supported with below known limitations

### ZodCatch

Only constant catch value is supported
```js
// constant value is supported
z.string().catch("fallback");

// catch function that returns a constant value is supported
z.string().catch(() => "fallback");

// this is also okay
const s = "fallback";
z.string().catch(() => s);

// this is not supported, because a different Date will be returned for each call; in this example, timestamp of when serialisation runs will be captured and is used as the catch value after deserialisation
z.date().catch(() => new Date());

```

---
_Source: https://npm.io/package/zodser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
