$ gnpm install is-zod
Typeguard to check if a value matches a zod schema.
If I should maintain this repo, please ⭐️
DM me on Twitter if you have questions or suggestions.
npm install is-zod
yarn add is-zod
pnpm add is-zod
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; }
}
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; }
}
Copyright 2013 - present © cnpmjs.org | Home |