Zod naming convention

What is the best naming convention for zod? both capitalized const Object = z.object(...) type Object = z.infer<...> -or- only type capitalized const object = z.object(...) type Object = z.infer<...>
7 Replies
Neto
Neto2y ago
i dont think there a convention just make them readable and it will be good enough usually u use something like
const createUserSchema = z.object(...)
type TCreateUser = z.infer<typeof createUserSchema>
const createUserSchema = z.object(...)
type TCreateUser = z.infer<typeof createUserSchema>
Nacho
NachoOP2y ago
hmm so you use different names?
Keef
Keef2y ago
I usually go by
const createUser = ....;
type CreateUser = z.infer...;
const createUser = ....;
type CreateUser = z.infer...;
there really isn't any wrong way to do it as long as u aren't misrepresenting it with a stupid name. Like the schema being responsible for log in and you instead call it "createUser"
Nacho
NachoOP2y ago
yeah that's pretty much what I'm doing, I was capitalizing both at first but thought it might lead to confusion
Keef
Keef2y ago
The convention with T in front is from C# I think, its upto you if you want to incorporate it. Usually having it as capitalized is enough to differentiate it in my eyes but u know how divided people can be on some things just do what works best for u and ur team
Neto
Neto2y ago
The T is just a optional "reminder" of sorts that is a type As long you can know that something is a type, it's a good use
Keef
Keef2y ago
Yeah I'm not knocking it. I picked it up for a bit and wasn't consistent with its usage so I just fell back to caps
Want results from more Discord servers?
Add your server