Zod + Generics is HEAVEN

Zod + Generics is HEAVEN

Matt Pocock

1 год назад

57,036 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@gantamk
@gantamk - 02.07.2024 21:57

Video is too fast. No sentence breaks, very difficult to follow.

Ответить
@tuananhdo1870
@tuananhdo1870 - 23.06.2024 19:38

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>;

Ответить
@mskleftwich
@mskleftwich - 05.04.2024 22:45

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!

Ответить
@somewonderfulguy
@somewonderfulguy - 29.03.2024 14:27

Ugh, feel dumb watching this video. Probably should rewatch it later after dealing with Zod in practice.

Ответить
@user-be3mg6cm4k
@user-be3mg6cm4k - 20.03.2024 00:16

Help! There are pieces of my mind everywhere, after that bombastic tip.

Ответить
@GdeVseSvobodnyeNiki
@GdeVseSvobodnyeNiki - 31.01.2024 01:14

Fuck zod, all my homies use io-ts!

Ответить
@SwedeOfEnbound
@SwedeOfEnbound - 28.01.2024 19:20

Hey Matt! Does your claim in ze title still hold up one year later? 🙏

Ответить
@pablom8854
@pablom8854 - 19.01.2024 20:41

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.

Ответить
@nomadshiba
@nomadshiba - 17.01.2024 16:44

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.

Ответить
@DanielRios549
@DanielRios549 - 16.01.2024 15:57

Zod is absolutely amazing, since you start using it, you never want to stop

Ответить
@mayankjain6440
@mayankjain6440 - 03.01.2024 17:05

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!

Ответить
@purduetom90
@purduetom90 - 13.11.2023 13:49

I slowed this down to 75% playback speed and it was still hard to follow

Ответить
@malipetek
@malipetek - 07.11.2023 17:00

I could not get it in one go, wow

Ответить
@martapfahl940
@martapfahl940 - 31.10.2023 22:20

is it comparable with pydantic speaking generally?

Ответить
@psyferinc.3573
@psyferinc.3573 - 25.09.2023 18:59

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

Ответить
@ThatRobHuman
@ThatRobHuman - 18.08.2023 22:26

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.

Ответить
@iquisickis2103
@iquisickis2103 - 16.08.2023 20:43

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

Ответить
@edgeeffect
@edgeeffect - 08.08.2023 01:18

This one's a bit TOO fast.

Ответить
@matthewbeardsley7004
@matthewbeardsley7004 - 27.07.2023 04:54

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

Ответить
@y.m.o6171
@y.m.o6171 - 12.06.2023 15:56

Thank you for this. Can you please please share the final code ?

Ответить
@MrCrooot
@MrCrooot - 06.06.2023 02:51

Don't change a thing, these are amazing.

Ответить
@0xlogn
@0xlogn - 15.05.2023 01:29

arktype > zod (disclosure: I'm an ArkType contributor)

Ответить
@itacirgabral1687
@itacirgabral1687 - 11.05.2023 01:00

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)

Ответить
@Danielo515
@Danielo515 - 22.04.2023 13:17

It’s not a validator , it’s a parser.

Ответить
@ufukbakan4741
@ufukbakan4741 - 17.04.2023 03:31

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.

Ответить
@user-gf9ri4wj5h
@user-gf9ri4wj5h - 17.04.2023 02:52

I can’t follow up with 0.75speed😂

Ответить
@saifullahrahman
@saifullahrahman - 29.03.2023 20:13

oh my god! this is exactly what I was trying to do just now.

Ответить
@user-kw9cu
@user-kw9cu - 08.03.2023 23:58

zoom out a little and do not cut in between it so hard to follow

Ответить
@pinch-of-salt
@pinch-of-salt - 03.03.2023 22:18

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.

Ответить
@reverser41
@reverser41 - 02.03.2023 15:00

Slow down.

Ответить
@matheusbaptista8904
@matheusbaptista8904 - 17.02.2023 04:58

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?

Ответить
@AjinkyaBorade
@AjinkyaBorade - 16.02.2023 20:14

Yup !

Ответить
@eula9
@eula9 - 11.02.2023 21:03

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

Ответить
@andrewblotski8526
@andrewblotski8526 - 09.02.2023 13:05

It would be great if you provide a link to the source code as Jack Herrington does

Ответить
@joostschuur
@joostschuur - 07.02.2023 10:40

I'm just here to point out that the blue color on your wall seems to be in your VS Code theme too.

Ответить
@ollyb8211
@ollyb8211 - 06.02.2023 02:20

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!

Ответить
@Wicked-Developer
@Wicked-Developer - 02.02.2023 10:45

You have great content, that's why I subscribed, but I find it difficult to follow the video.

Ответить
@mahmutjomaa6345
@mahmutjomaa6345 - 02.02.2023 06:25

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().

Ответить
@CristianPerezRodriguez
@CristianPerezRodriguez - 02.02.2023 04:57

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.

Ответить
@botatoo1733
@botatoo1733 - 01.02.2023 08:38

plot twist you use Yup instead of zod for a day

Ответить
@froxx93
@froxx93 - 01.02.2023 00:54

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.

Ответить
@aungmyatmoemakescodework
@aungmyatmoemakescodework - 30.01.2023 15:35

instead of casting as any, we can use return cb(req as Request<any, any, any, TQuery>, res); like this

Ответить
@warrenlayson2514
@warrenlayson2514 - 30.01.2023 12:01

But our senior devs are either too bland or lazy for innovations

Ответить
@benoitleger-derville6986
@benoitleger-derville6986 - 29.01.2023 17:06

Are all aspects of this video well covered in your course on Zod?

Ответить
@noamisaac
@noamisaac - 28.01.2023 19:32

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

Ответить
@johnjohn7023
@johnjohn7023 - 28.01.2023 18:14

this is too fast. my head is spinning now. no joke.

Ответить
@Oussama-uo1gf
@Oussama-uo1gf - 27.01.2023 23:29

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

Ответить
@peterprog181
@peterprog181 - 27.01.2023 17:26

My brain is driving at 300kmh

Ответить
@TheWalrus_45
@TheWalrus_45 - 27.01.2023 13:45

As much as I wanted to learn how to Build ANYTHING with Zod + Generics, none of that made any sense to me :/

Ответить