How to use the zod.object function in zod

To help you get started, we’ve selected a few zod examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github molenzwiebel / Mimic / rift / src / web.ts View on Github external
app.post("/v1/notifications/subscribe", async (req, res) => {
    if (!z.object({
        uuid: z.string(),
        token: z.string(),
        type: z.string()
    }).check(req.body) || !NOTIFICATION_TYPES.includes(req.body.type)) {
        return res.status(400).json({
            ok: false,
            error: "Invalid request."
        });
    }

    const code = await tokens.verifyPushNotificationToken(req.body.token);
    if (!code) return res.status(403).json({
        ok: false,
        error: "Invalid token."
    });

zod

TypeScript-first schema declaration and validation library with static type inference

MIT
Latest version published 14 days ago

Package Health Score

100 / 100
Full package analysis

Popular zod functions