Created
April 7, 2025 09:56
-
-
Save cuongboi/de4a43c9f4ee117502a8c861708c641e to your computer and use it in GitHub Desktop.
Nextjs Router Decorator Example Schema
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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