Skip to content

Directly use zod schema in validate #2

@apeman76

Description

@apeman76

Hi, im trying to get the type safety working with my API but I already have a ton of zod schemas defined in another file, when I try to use these it wont work.

	const { data } = await validate(request, {
		mySchema
	});

gives
Error: "Invalid data: at 'mySchema': 'Required'."

	const { data } = await validate(request, {
		...mySchema.shape
	});

gives
error when starting dev server: TypeError: Cannot read properties of undefined (reading 'getBaseTypes')

const { data } = await validate(request, mySchema);
gives
Argument of type 'ZodObject<{ mystuff }, "strip", ZodTypeAny, { ...; }, { ...; }>'.

Is there any way to make this work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions