Metadata-Version: 2.4
Name: envproof
Version: 0.1.0
Summary: Validate environment variables at startup with typed, clear error messages. Zero dependencies.
Project-URL: Homepage, https://github.com/CoderSufiyan/envguard
Project-URL: Repository, https://github.com/CoderSufiyan/envguard
Project-URL: Issues, https://github.com/CoderSufiyan/envguard/issues
License: MIT
Keywords: config,dotenv,env,environment,settings,validation
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# envguard

Validate environment variables at startup with typed, clear error messages. Zero dependencies.

```python
from envguard import EnvGuard

class Env(EnvGuard):
    DATABASE_URL: str
    PORT: int = 8080
    DEBUG: bool = False
    ALLOWED_HOSTS: list = []

env = Env()
print(env.PORT)  # 8080 (int, not string)
```

If `DATABASE_URL` is missing, you get this instead of a cryptic `KeyError` somewhere deep in your app:

```
EnvGuardError:
Missing required environment variables:
  - DATABASE_URL (str): not set
```

## Install

```bash
pip install envguard
```

## Usage

### Subclass style (recommended)

```python
from envguard import EnvGuard

class Env(EnvGuard):
    # Required — raises if not set
    DATABASE_URL: str
    API_KEY: str

    # Optional — uses default if not set
    PORT: int = 8080
    DEBUG: bool = False
    LOG_LEVEL: str = "INFO"
    ALLOWED_HOSTS: list = []

env = Env()
```

### One-liner style

```python
from envguard import guard

env = guard(DATABASE_URL=str, PORT=int, DEBUG=bool)
print(env.DATABASE_URL)
```

## Supported types

| Type    | Example env value         | Python value             |
|---------|---------------------------|--------------------------|
| `str`   | `"hello"`                 | `"hello"`                |
| `int`   | `"8080"`                  | `8080`                   |
| `float` | `"3.14"`                  | `3.14`                   |
| `bool`  | `"true"`, `"1"`, `"yes"`  | `True`                   |
| `bool`  | `"false"`, `"0"`, `"no"`  | `False`                  |
| `list`  | `"a,b,c"`                 | `["a", "b", "c"]`        |

## Error messages

All errors are collected and reported together — you won't fix one missing var only to discover another:

```
EnvGuardError:
Missing required environment variables:
  - DATABASE_URL (str): not set
  - API_KEY (str): not set

Invalid environment variable values:
  - PORT: expected int, got 'abc'
  - DEBUG: expected bool, got 'maybe'
```

## Why not pydantic-settings?

`pydantic-settings` is great but pulls in Pydantic as a dependency (~2MB). `envguard` is a single file with zero dependencies — useful when you want validation without adding weight to your project.

## License

MIT
