ctroenv validate
Validate environment variables against your schema.
Usage
ctroenv validate [options]Options
| Option | Type | Default | Description |
|---|---|---|---|
--source | string | process.env | Path to a .env file |
--strict | boolean | false | Treat warnings as errors |
--watch | boolean | false | Watch for file changes |
--json | boolean | false | Output as JSON |
Examples
Basic validation
ctroenv validateValidates against process.env using the schema from ctroenv.config.ts.
With .env file
ctroenv validate --source .env.localWatch mode
ctroenv validate --watchRe-validates when your schema or env files change. Useful during development.
JSON output
ctroenv validate --jsonOutputs validation results as JSON for programmatic consumption:
{
"valid": false,
"source": ".env",
"total": 5,
"errors": 2,
"variables": [
{
"key": "DATABASE_URL",
"type": "string",
"value": "postgresql://...",
"required": true,
"description": "Primary database connection",
"isSecret": false,
"hasDefault": false
}
]
}Exit Codes
| Code | Meaning |
|---|---|
0 | All variables valid |
1 | Validation errors found |
2 | Configuration error |