ctroenv validate
Validate current environment variables against your schema from the CLI.
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 |
--watch | boolean | false | Watch for file changes |
--json | boolean | false | Output as JSON |
Examples
Basic validation
ctroenv validate
Validates against process.env using the schema from ctroenv.config.ts.
With .env file
ctroenv validate --source .env.local
Watch mode
ctroenv validate --watch
Re-validates when your schema or env files change. Useful during development.
JSON output
ctroenv validate --json
Outputs 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 |
How is this guide?
Last updated on Jun 24, 2026