is-zod
Typeguard to check if a value matches a zod schema
Last updated 2 years ago by bconnorwhite .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install is-zod 
SYNC missed versions from official npm registry.

is-zod

NPM TypeScript

Typeguard to check if a value matches a zod schema.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


Installation

npm install is-zod
yarn add is-zod
pnpm add is-zod

Usage

Is

import { z } from 'zod';
import is from 'is-zod';

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

const value = {
  name: 'Bob',
  age: 42
};

if(is(value, user)) {
  // value is typed as { name: string; age: number; }
}

Validate

import { z } from 'zod';
import { validate } from 'is-zod';

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

const isUser = validate(user);

const value = {
  name: 'Bob',
  age: 42,
};

if(isUser(value)) {
  // value is typed as { name: string; age: number; }
}

Dependenciesdependencies

  • zod: TypeScript-first schema declaration and validation library with static type inference

Dev Dependencies

  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

License license

MIT

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (1)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |