0.14.1 • Published 3 months ago

@spectrajs/zod v0.14.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@spectrajs/zod

codecov GitHub Workflow Status License npm npm Bundle Size

A validator middleware using Zod for Spectra.

Installation

npm install @spectrajs/zod

Documentation

The documentation is available here.

Usage

import { Spectra } from "@spectrajs/core";
import { z } from "zod";
import { zodValidator } from "@spectrajs/zod";

const app = new Spectra();

const schema = z.object({
  name: z.string(),
  age: z.number(),
});

app.post("/post", zodValidator("json", schema), async (c) => {
  const { name, age } = c.req.valid<z.infer<typeof schema>>("json");
  return c.json({ name, age });
});

export default app;

License

Distributed under the MIT License. See LICENSE for more information.

0.14.1

3 months ago

0.14.0

3 months ago

0.13.0

4 months ago