naz6352
TTCTheo's Typesafe Cult
•Created by Mir on 5/13/2023 in #questions
Zod conditional required/optional validation
I used to do it via
.refine
too but then I discovered that if you do it this way the type of z.infer<typeof schema>
is
which is very nice 🙂29 replies
TTCTheo's Typesafe Cult
•Created by Mir on 5/13/2023 in #questions
Zod conditional required/optional validation
And to include
otherNonMatchingKey
I've done it before via this sort of pattern
29 replies
TTCTheo's Typesafe Cult
•Created by Mir on 5/13/2023 in #questions
Zod conditional required/optional validation
There is also z.discriminatedUnion
https://zod.dev/?id=discriminated-unions
So you could do something like
29 replies
TTCTheo's Typesafe Cult
•Created by Froxx on 2/9/2023 in #questions
Clean definition of models using Zod schemas
The way that I handled ids was to make this:
And then attach it to anything that needs an id
I did something similar with updatedAt / createdAt timestamps, which ended up being very helpful when I changed them from
z.date()
to z.coerce.date()
once that feature came out, didn't have to change it in a dozen places.
As for your problem with refines, it is possible to add a ZodEffect
as a property in a ZodObject
, if that helps you solve some of the issue.
6 replies
TTCTheo's Typesafe Cult
•Created by nexxel on 11/21/2022 in #questions
jwt vs cookies in next-auth
Found the blog with that flowchart on the prisma-session-store readme if you want to read the rest of it (there's a couple other links mentioned in the readme that are pretty good reads too) https://github.com/kleydon/prisma-session-store
151 replies
TTCTheo's Typesafe Cult
•Created by nexxel on 11/21/2022 in #questions
jwt vs cookies in next-auth
A bit late to the party but I found this cool flowchart that describes some problems with using JWT for sessions http://cryto.net/~joepie91/blog/attachments/jwt-flowchart.png
151 replies
TTCTheo's Typesafe Cult
•Created by zenith on 10/18/2022 in #questions
Stack suggestion - DB platform for a larger number of smaller projects
You can only have a single project on the free plan, if you want more you need the scaler plan and it's $30/mo per
25 replies