How to Validate Environment Variables Without a Library (And Why You Should Anyway)

I'm a fan of minimal dependencies. Every library you add is code you don't control, surface area for bugs, and another thing to keep up to date. So when I started a new project last month, I told myself: no env validation library. I'll write it myself. It's just a few vars.

Six hours later I had a surprisingly solid little validation function. Let me show you what I built.

Part 1: Your Own Env Validation in Plain TypeScript

Here's the complete thing, about 60 lines: