zod-prisma-types icon indicating copy to clipboard operation
zod-prisma-types copied to clipboard

[Feature Request] Make field required in resulting schema, but optional in DB

Open CyanoFresh opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. Add ability to mark field "required", even if it is optional in prisma schema (with ? mark)

model Model {
fieldA Int? /// @zod.custom.use(z.number().int().positive())
}

results in:

fieldA: z.number().int().positive().nullish(),

but desired:

fieldA: z.number().int().positive(),

Describe the solution you'd like

  • @zod.custom.use() should not implicitly add .optional() or .nullish() to the end of type
  • @zod.[...].required() will not make this field nullish

Describe alternatives you've considered Extending a scheme and overwriting this field's type

CyanoFresh avatar Dec 01 '23 18:12 CyanoFresh