πΏ The ONLY TypeScript validation runtime library you'll need πͺπ«
Hey friend,
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!
βThe REAL reason youβre not a Senior Engineer π
β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.
The 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:
βπ₯ Loved itβ
βπ Not badβ
βπ You can make it betterβ
I hope you have a great day!
P.S.