I have the following zod schema, and in some cases there is a field I would like to omit from the schema entirely. I can't just make it optional. I suspect there is some way do it with zod directly. Is there a way to omit fields or to preprocess the schema in some way?
For example, how I can use this schema without this nested field.
const schema = z.object({
name: z.number(),
age: z.number(),
data: z.array(
z.object({
id: z.string().optional(),
name: z.string().nonempty().optional(),
})
)
});
const test = schema.shape.data //. ??? how can I omit the name field?
type typeTest = z.infer<typeof test>; // just data without name field
How I can omit this nested value?