- Great idea to parse everything coming into your program from the outside
- Not sure why I’ve made do with mystery strings for so long
- Makes me think of “parse, don’t validate”
Original video by Lazar Nikolov:
Validate your environment variables with Zod! process.env by default does not automatically pick up the environment variables that you define. It also can’t validate if all the required variables are set, so you’ll get an error during runtime if they’re not. We can fix that by using Zod to create a schema of our env variables and validate process.env against it. Exporting the schema will also provide us with the correct types, so we won’t mistype an environment variable ever again.
🔗 Links:
👉 Zod: https://zod.dev
👉 Read the article: https://creatures.sh/blog/env-type-safety-and-validation/
—
🤝 Become a friend of the channel! Start your membership today and get extra benefits: https://youtube.com/@nikolovlazar/join
💬 A bunch of us are hanging out at https://discord.creatures.sh/. Join us!
🐦 Find me on the bird app: https://twitter.com/NikolovLazar
🎥 What I use for coding and making videos: https://nikolovlazar.com/uses