🍿 The ONLY TypeScript validation runtime library you'll need 🪄💫
Every developer aspires to climb the career ladder and evolve into a more senior, leadership role. However, many find this progression challenging or don't get to the level they want.
If you are preparing for a senior role or are just a few years away, I have compiled five key strategies that every developer must pursue to reach seniority.
If you prefer watching a video, then check out this video!
Don't forget to subscribe to my Youtube channel! if you haven't already!
Weekly Snack: Zod Schema Validation 🍿
Zod provides TypeScript first schema validation.
It allows you to check types at the runtime level as well at the type level. It's easier to validate your schema and complex data structures.
z is an instance of the "zod" library, and
z.object() is used to define a schema for an object.
We create a validation schema for an object with "name" and "amount" fields. It then attempts to validate an object (likely received from a form submission) against this schema.
- The "name" field should be a non-empty string.
- The "amount" field should be a number greater than 0.
safeParse method does the following:
If the validation is successful, the result object will have a
success property set to
true and the parsed data.
If validation fails, it will have
success set to
false, and there might be an
error property with details about the failure.
To check out the power of Zod, check out this advanced example of Zod:
The Frontend Developers Toolbox 🧰
- Free Tailwind Crash Course by yours truly!
- Create AI Emoji's: Turn your ideas into emojis in seconds. Generate your favorite Slack emojis with just one click.
That's all for today; keep learning and growing!
Was this useful? With your feedback, I can improve future emails. Click on a link to vote:
I hope you have a great day!