0.0.4 • Published 9 months ago

@criterium/zod v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

@criterium/zod

@criterium/zod create zod query schema for given zod entity schema.

install

npm i @criterium/zod

usage

import { z } from 'zod';
import { queryOf } from '@criterium/zod';

const User = z.object({
  name: z.string(),
  address: z.object({
    street: z.string(),
  }),
});

const UserQuery = queryOf(User);

UserQuery.safeParse({
  address: {
    street: {
      $in: ['SF', 'NY'],
    },
  },
});
// success

UserQuery.safeParse({
  is_admin: {
    $eq: true,
  },
});
// fail
0.0.4

9 months ago

0.0.3

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago