Skip to content

Command Line Tools

Wheels env validate

The wheels env validate command validates the format and content of .env files in your Wheels project. This command helps ensure your environment configuration is properly formatted, contains required variables, and follows best practices. It’s essential for catching configuration errors before deployment and maintaining consistent environment setups across different environments.

Terminal window
wheels env validate [options]
OptionDescriptionDefault
--fileName of the .env file to validate.env
--requiredComma-separated list of required keys that must be presentempty
--verboseShow detailed validation information including all variablesfalse
Terminal window
wheels env validate

Validates the .env file in your project root

Terminal window
wheels env validate --file=.env.production

Validates the .env.production file

Terminal window
wheels env validate --required=DB_HOST,DB_USER,DB_PASSWORD

Validates that specific required variables are present

Terminal window
wheels env validate --verbose

Shows detailed information about all variables found

Terminal window
wheels env validate --file=.env.production --required=DB_HOST,DB_NAME,DB_USER,DB_PASSWORD,API_KEY

Ensures production environment has all critical variables

Terminal window
# Validate all environment files
wheels env validate --file=.env.development
wheels env validate --file=.env.staging
wheels env validate --file=.env.production
Terminal window
# Development requirements
wheels env validate --file=.env.development --required=DB_HOST,WHEELS_ENV
# Production requirements
wheels env validate --file=.env.production --required=DB_HOST,DB_NAME,DB_USER,DB_PASSWORD,API_KEY,WHEELS_ENV
Terminal window
wheels env validate --file=.env.production --required=DB_HOST,API_KEY --verbose

Combines required variable checking with detailed output

The command validates several aspects of your .env file format:

  • Properties format: Standard KEY=VALUE pairs
  • JSON format: Valid JSON structure
  • Automatic detection based on content
  • Missing equals sign: KEY VALUE (invalid)
  • Empty key names: =value (invalid)
  • Valid key=value format: KEY=value (valid)
  • Valid characters: Letters, numbers, underscores only
  • Standard format: UPPER_SNAKE_CASE recommended
  • Non-standard warnings: Mixed case, special characters
Terminal window
wheels env validate --required=DB_HOST,API_KEY

Ensures specified variables are present and have values

Identifies when the same key appears multiple times:

Line 15: Duplicate key: 'DB_HOST' (previous value will be overwritten)

Identifies common placeholder values in sensitive variables:

  • your_password
  • your_secret
  • change_me
  • xxx
  • TODO
==================================================
Validating: .env
==================================================
Summary
--------------------------------------------------
Total variables: 4
[SUCCESS]: Validation passed with no issues!
Validating: .env.development
Warnings:
Line 5: Non-standard key name: 'dbHost' (should contain only letters, numbers, and underscores)
Line 12: Placeholder value detected for 'API_KEY'
Summary:
Total variables: 8
Validation passed with 2 warnings
==================================================
Validating: .env
==================================================
[FAILED]: Errors found:
- Required key missing: 'DB_HOST'
- Required key missing: 'API_KEY'
Summary
--------------------------------------------------
Total variables: 4
[FAILED]: Validation failed with 2 errors
==================================================
Validating: .env
==================================================
Summary
--------------------------------------------------
Total variables: 4
Environment Variables:
--------------------------------------------------
wheels:
- wheels_env = development
DB:
- DB_USER = root
- DB_NAME = myapp
- DB_PORT = 3306
API:
- API_BASE_URL = https://api.example.com
- API_KEY = ***MASKED***
- API_TIMEOUT = 30
Other:
- APP_NAME = My Application
- WHEELS_ENV = development
[SUCCESS]: Validation passed with no issues!
Error: Line 5: Invalid format (missing '='): DB_HOST localhost

Solution: Add equals sign: DB_HOST=localhost

Error: Line 8: Empty key name

Solution: Provide a key name: MY_KEY=value

Error: Invalid JSON format: Unexpected character at position 15

Solution: Fix JSON syntax or convert to properties format

Error: Required key missing: 'API_KEY'

Solution: Add the missing variable: API_KEY=your-api-key

Warning: Required key has empty value: 'DB_PASSWORD'

Solution: Provide a value: DB_PASSWORD=your-password

Warning: Line 3: Non-standard key name: 'dbHost' (should contain only letters, numbers, and underscores)

Recommendation: Use DB_HOST instead of dbHost

Warning: Line 7: Placeholder value detected for 'API_KEY'

Recommendation: Replace placeholder with actual value

Warning: Line 12: Duplicate key: 'DB_PORT' (previous value will be overwritten)

Recommendation: Remove duplicate or rename one key

Terminal window
# Validate production config before deployment
wheels env validate --file=.env.production --required=DB_HOST,DB_NAME,DB_USER,DB_PASSWORD,API_KEY
# Check staging environment
wheels env validate --file=.env.staging --required=DB_HOST,API_KEY
Terminal window
# Quick validation during development
wheels env validate
# Detailed check when debugging
wheels env validate --verbose
Terminal window
# In your deployment pipeline
wheels env validate --file=.env.production --required=DB_HOST,API_KEY
if [ $? -ne 0 ]; then
echo "Environment validation failed!"
exit 1
fi
Terminal window
# Validate new team member's setup
wheels env validate --required=DB_HOST,WHEELS_ENV,API_KEY
# Check if all environments are properly configured
for env in development staging production; do
wheels env validate --file=.env.$env
done
Terminal window
# Regular audit of all environment files
wheels env validate --file=.env.development --verbose
wheels env validate --file=.env.production --verbose
Terminal window
# Add to your development routine
wheels env validate
Terminal window
# Define different requirements for different environments
wheels env validate --file=.env.development --required=DB_HOST,WHEELS_ENV
wheels env validate --file=.env.production --required=DB_HOST,DB_NAME,DB_USER,DB_PASSWORD,API_KEY
# Add to git pre-commit hooks
#!/bin/sh
wheels env validate --file=.env.example
Terminal window
# In CI/CD pipeline
wheels env validate --file=.env.production --required=DB_HOST,API_KEY
Terminal window
# Generate configuration documentation
wheels env validate --verbose > config-validation-report.txt
Terminal window
# Set variables then validate
wheels env set DB_HOST=localhost DB_PORT=3306
wheels env validate --required=DB_HOST,DB_PORT
Terminal window
# Merge files then validate result
wheels env merge .env.base .env.local --output=.env.merged
wheels env validate --file=.env.merged --required=DB_HOST,API_KEY
Terminal window
# Validate then show configuration
wheels env validate --verbose
wheels env show

The command returns different exit codes for automation:

  • 0: Validation passed (may have warnings)
  • 1: Validation failed (has errors)

This makes it perfect for use in scripts and CI/CD pipelines:

Terminal window
if wheels env validate --file=.env.production; then
echo "Production config is valid"
# Continue with deployment
else
echo "Production config has errors"
exit 1
fi
  • Use the validation to catch placeholder values in sensitive variables
  • Regularly validate that required security-related variables are present
  • Use --verbose mode carefully in CI/CD (sensitive values are masked but logs might be visible)
  • Validate environment files before committing changes
  • Use different required variable lists for different environments
  • Set up validation as part of your local development setup script
  • Include validation in project setup documentation
  • Use validation to ensure consistent environment setup across team members
  • Define standard required variables for your project type
  • Integrate validation into deployment pipelines
  • Use exit codes to fail deployments when validation errors occur
  • Set up regular validation checks for configuration drift detection