Skip to content

Instantly share code, notes, and snippets.

@cuongboi
Created April 7, 2025 09:56
Show Gist options
  • Save cuongboi/de4a43c9f4ee117502a8c861708c641e to your computer and use it in GitHub Desktop.
Save cuongboi/de4a43c9f4ee117502a8c861708c641e to your computer and use it in GitHub Desktop.
Nextjs Router Decorator Example Schema
import { z } from "zod";
export const UserObject = z.object({
id: z.string().default("1").describe("User ID"),
username: z.string().min(3, "Username must be at least 3 characters long"),
email: z.string().email("Invalid email address"),
password: z.string().min(6, "Password must be at least 6 characters long"),
});
export const RegisterUser = UserObject.omit({
id: true,
});
export const User = UserObject.omit({ password: true });
export const Users = z.array(User);
export type RegisterUser = z.infer<typeof RegisterUser>;
export type User = z.infer<typeof User>;
export type Users = z.infer<typeof Users>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment