Skip to content

Commit

Permalink
chore(types): improve extended zod types
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Feb 21, 2024
1 parent 92b8347 commit c03a3ad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/server/utils/zod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { z as zod } from 'zod'

export const z = {
interface ExtendedZodMethods {
intAsString: () => zod.ZodEffects<zod.ZodString, number, string>
}
type ExtendedZod = typeof zod & ExtendedZodMethods

export const z: ExtendedZod = {
...zod,
intAsString: () => zod.string().transform(val => parseInt(val, 10))
}

0 comments on commit c03a3ad

Please sign in to comment.