Course lesson

Use parse and safeParse Runtime Type-checks with zod

You might want to run zod schema checks in different styles.

Duration
8 min
Access
Included
Transcript
Needs source

You might want to run zod schema checks in different styles.

Sometimes you prefer to conditionally throw the error - that's what parse does. But another time you'd prefer to receive a boolean property that determines whether the validation was successful or not - and perform further actions accordingly.

Additionally, the error-throwing API of parse works extremely well with TypeScript assertion functions. Their combination is just... perfect! 👌

That's what we learn in this lesson.