Skip to content

Instantly share code, notes, and snippets.

@kdaisho
Last active December 18, 2023 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdaisho/e1fffab7055a2cdb0a94c3eda24505f6 to your computer and use it in GitHub Desktop.
Save kdaisho/e1fffab7055a2cdb0a94c3eda24505f6 to your computer and use it in GitHub Desktop.
import type { z } from 'zod';
const mySchema = z.object({
limit: z.number().default(10),
offset: z.number().default(0),
filter: z.object({
requested: z.boolean(),
pending: z.boolean(),
approved: z.boolean(),
removed: z.boolean(),
promoted: z.boolean(),
}),
});
// extracting type from zod schema
type Filter = keyof z.infer<typeof mySchema>['filter']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment