Комментарии:
Video is too fast. No sentence breaks, very difficult to follow.
Ответитьfunction useFormZod<T>(schema: z.Schema<T>, onSubmit: (values: T) => void) {
return {
onSubmit: (values: unknown) => {
const newValue = schema.parse(values);
return onSubmit(newValue);
},
};
}
const { onSubmit: handleCreatePost } = useFormZod(
z.object({ name: z.string(), description: z.string().optional() }),
(values) => {
console.log("aaa values", values);
createPost(values);
},
);
<form onSubmit={handleCreatePost}></form>;
This is so great. Small bit of feedback: could have used an extra second or two to read each code snippet before you moved to the next thing. I ended up just watching at 0.75 and pausing as needed. Thanks for the great content as always!
ОтветитьUgh, feel dumb watching this video. Probably should rewatch it later after dealing with Zod in practice.
ОтветитьHelp! There are pieces of my mind everywhere, after that bombastic tip.
ОтветитьFuck zod, all my homies use io-ts!
ОтветитьHey Matt! Does your claim in ze title still hold up one year later? 🙏
Ответитьworking with Zod and Prisma has been really hard, not sure if my logic is wrong but Zod + Mongoose was a lot easier. I'm having all sorts of issues with Prisma and models relations, it has been hard and I'm even using a generator to generate the Zod schemas.
Ответитьyou can use `as never` there
you never really have to use `as any` for anything.
you can just ban `: any` and `as any` from typescript literally, you never need it.
if you think that you need `any` as a value type, you either need `unknown` or `never` every time.
Zod is absolutely amazing, since you start using it, you never want to stop
ОтветитьHey Matt, I like the content, it is very informative but it could be better if pace of the explanation, flow of the code would have been taken care of! Hope you'll consider feedback and will deliver such nice content ahead!
ОтветитьI slowed this down to 75% playback speed and it was still hard to follow
ОтветитьI could not get it in one go, wow
Ответитьis it comparable with pydantic speaking generally?
Ответитьah i really should get over your beginners ts to get a hang of your style. the information is too much and too beautiful for me to be lazy about the basics. thank you a lot for your content man. you really are a wizard
ОтветитьI'm sorry man, I really tried, but I feel like this video is like drinking from a firehose, to the point where I couldn't even pause fast enough. and it's really hard to follow what is going on. plus, there's not even any kind of code or github repo in the description so one can try to find their own context, which is a shame because the express/zod pattern is exactly what I'm hoping to use, and this is not helpful.
ОтветитьI now understand the power of zod + generics!
It gives me the idea to create an angular service which checks any received dto schemas then throw verification errors with explicit messages thanks to zod-validation-error package
This one's a bit TOO fast.
ОтветитьLol, okay I feel a bit better seeing others not being able to follow along, I'll have to watch this a few times to grasp it...I felt like I had it on 1.5x anyway, I wouldn't change too much, I like all your videos
ОтветитьThank you for this. Can you please please share the final code ?
ОтветитьDon't change a thing, these are amazing.
Ответитьarktype > zod (disclosure: I'm an ArkType contributor)
Ответитьimport { z } from 'zod'
const loginFormSchema = z.object({
email: z.string().email(),
password: z.string()
})
const useForm = <T>(
schema: z.Schema<T>,
onSubmit: (values: T) => void
) => {
return {
onSubmit: (values: unknown) => {
const parsedValues = schema.parse(values)
onSubmit(parsedValues)
}
}
}
const form = useForm(loginFormSchema, console.dir)
It’s not a validator , it’s a parser.
ОтветитьYou can use 'bootpress' on npm, i coded it for backend with the similar approach but i coded the 'zod part' my own too so it doesnt have dependency to it.
ОтветитьI can’t follow up with 0.75speed😂
Ответитьoh my god! this is exactly what I was trying to do just now.
Ответитьzoom out a little and do not cut in between it so hard to follow
ОтветитьDamn had to freeze frame a lot to grasp everything, really informative video btw. It would be great if you could start with some code then try to show how it’s flawed and then fix it.
ОтветитьSlow down.
ОтветитьHi Matt, congratulations on the video!
So imagine that my schema is a z.object with 70 properties and I create a type alias from the z.infer of this object, so when I hover over this type vscode won't be able to show me the complete structure of type in your hover tooltip, it will show me something like ... 60 more ...
Do you have any suggestions on how I can visually check the structure of the type alias that z.infer would generate for me when I have a schema with many properties?
Yup !
Ответитьso happy its not just me that can't follow this, i felt so stupid for not being able to lol. what's the philosophy behind ruthlessly trying to optimize shortening the video length? i got time don't worry
ОтветитьIt would be great if you provide a link to the source code as Jack Herrington does
ОтветитьI'm just here to point out that the blue color on your wall seems to be in your VS Code theme too.
ОтветитьIf you’re intrigued by the premise of using Zod to make your REST endpoints type safe, give ts-rest a go. It’s a tiny lib, we use the same premises Matt talks about here, but take care of the difficult generics for you.
Enjoy!
You have great content, that's why I subscribed, but I find it difficult to follow the video.
ОтветитьHow would you validate iso 8601 datetime? It comes as a string to the endpoint. You can either call .coerce.date() or call .string().datetime().
ОтветитьI think it would be much better to make short videos instead of fast ones. You are just "cheating" here because understanding all this would basically require pausing the video several times and that's not fast at all. And would definitely appreciate if you could talk more slowly, not all of us are native English speakers. And no offense but everytime you showed your face it distracted me from the code that I was trying to understand as well. Sorry if the feeback is harsh, I really want your channel to succeed so that's why I'm sharing.
Ответитьplot twist you use Yup instead of zod for a day
ОтветитьI know a lot your videos like this are intentionally just scratching the surface of a topic, and are at least partially meant to refer people to your full guides, but I'd still recommend slowing down a little on the info-per-time-ratio. Even for me, who knows most of the things you talked about in this vid, it was pretty hard to follow.
Ответитьinstead of casting as any, we can use return cb(req as Request<any, any, any, TQuery>, res); like this
ОтветитьBut our senior devs are either too bland or lazy for innovations
ОтветитьAre all aspects of this video well covered in your course on Zod?
ОтветитьIs there anywhere we can actually access the code you write in the video? I would like to follow with a stable point of reference
Ответитьthis is too fast. my head is spinning now. no joke.
Ответитьit's so hard to get what's going on with all the sudden transitions. Love the way you explain though, keep up the good work
ОтветитьMy brain is driving at 300kmh
ОтветитьAs much as I wanted to learn how to Build ANYTHING with Zod + Generics, none of that made any sense to me :/
Ответить