# @daotl/edgedb-zod

> Creates Zod schemas for your EdgeDB types

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

## Install

```sh
npm install @daotl/edgedb-zod
pnpm add @daotl/edgedb-zod
yarn add @daotl/edgedb-zod
bun add @daotl/edgedb-zod
```

Provides the command `edgedb-zod`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta4 |
| Published | 2023-02-03 |
| First published | 2023-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Sikarii |
| Maintainers | nex |
| Keywords | edgedb, zod, schema, generator |

## Links

- npm: https://www.npmjs.com/package/@daotl/edgedb-zod
- Repository: https://github.com/daotl/edgedb-zod
- Homepage: https://github.com/daotl/edgedb-zod#readme
- Issues: https://github.com/daotl/edgedb-zod/issues
- npm.io page: https://npm.io/package/@daotl/edgedb-zod

## Dependencies (3)

- [zod](https://npm.io/package/zod.md) ^3.19.0
- [yargs](https://npm.io/package/yargs.md) ^17.6.0
- [edgedb](https://npm.io/package/edgedb.md) ^1.0.0

## 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

- 1.0.0-beta4 (latest) — 2023-02-03
- 0.0.0 — 2023-02-03

## README

# edgedb-zod

`edgedb-zod` is a code generator for [Zod](https://github.com/colinhacks/zod) schemas from your EdgeDB database schema.

2 types of schemas will be generated:
- `Create`: All properties excluding link properties
- `Update`: All properties excluding link and readonly properties

## CLI

To run the CLI: `edgedb-zod [options]`

Currently the supported options are:
- `--outputDir`: The output directory relative from your `edgedb.toml`
- `--target ts|mts`: If set to `mts` will include `.js` in import statements

## Supported features

| Feature | Status |
| ------- | :----: |
| Most scalars          | ✔️ |
| Ranges                | ❌ |
| Arrays, tuples        | ✔️ |
| Union types           | ❌ |
| Abstract objects      | ✔️ |
| Overloaded properties | ✔️ |
| Regex constraints     | ✔️ |
| Min, max constraints  | ❌ |
| Custom validators     | ❌ |
| Property annotations  | ❌ |

## Example output

Partial output of `edgedb-zod/modules/default.ts`:
```ts
// #region default::User
export const CreateUserSchema = z.
  object({ // default::HasTimestamps
    createdAt: z.date().optional(), // std::datetime
    updatedAt: z.date().optional(), // std::datetime
  })
  .extend({ // default::User
    name: z.string(), // std::str
    emailAddress: z.string().regex(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/), // std::str
    password: z.string(), // std::str
  });

export const UpdateUserSchema = z.
  object({ // default::HasTimestamps
    updatedAt: z.date().optional(), // std::datetime
  })
  .extend({ // default::User
    name: z.string(), // std::str
    emailAddress: z.string().regex(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/), // std::str
    password: z.string(), // std::str
  });
// #endregion
```

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