Mir
Mir
TTCTheo's Typesafe Cult
Created by Mir on 6/27/2023 in #questions
parse string as duration, are we stuck with momentjs?
4 replies
TTCTheo's Typesafe Cult
Created by Mir on 6/5/2023 in #questions
[PRISMA] Adding method with param in result object
Hi, I have seen the documentation about adding method to the result object. I would like to add a method with parameter, NOT static method in result object. Is that possible? https://www.prisma.io/docs/concepts/components/prisma-client/client-extensions/result#add-a-custom-method-to-the-result-object
const user = await prisma.user.findUniqueOrThrow({ where: { id: someId } })
user.generateDiscount(discountPercent)
const user = await prisma.user.findUniqueOrThrow({ where: { id: someId } })
user.generateDiscount(discountPercent)
11 replies
TTCTheo's Typesafe Cult
Created by Mir on 5/13/2023 in #questions
Zod conditional required/optional validation
I am using React Hook Form and Zod. I want make some fields optional/required based on other inputs. Here's an example:
const schema = z.object({
type: z.enum(['image', 'video', 'image-and-video', 'other']),
image: z.custom<File>(),
video: z.custom<File>(),
otherNonMatchingKey: z.custom<File>(),
})
const schema = z.object({
type: z.enum(['image', 'video', 'image-and-video', 'other']),
image: z.custom<File>(),
video: z.custom<File>(),
otherNonMatchingKey: z.custom<File>(),
})
I want image to be required only when type: image is selected and vice-versa.
29 replies
TTCTheo's Typesafe Cult
Created by Mir on 3/6/2023 in #questions
Does Prisma has Multi-tenant feature? 👀
If you could suggest any alternative solution that will be helpful too!
2 replies
TTCTheo's Typesafe Cult
Created by Mir on 11/17/2022 in #questions
How should I organize my app where it has different behavior in responsive layout?
12 replies
TTCTheo's Typesafe Cult
Created by Mir on 9/30/2022 in #questions
Why typescript type inference is behaving like this?
7 replies