Validate Environment Variables with Pydantic
Tip! Validate your env vars from your .env files before they hit your application by using Pydantic. This also eliminates the need to call python-dotenv manually.
Here's an example:
# uv add pydantic pydantic-settings python-dotenv
from pydantic import Field, AnyHttpUrl, ValidationError
from pydantic_settings import BaseSettings, SettingsConfigDict
# Define settings