feat: extract .env validators to common.sh and add validate_env()
Move 10 validation functions from configure_env.sh to lib/common.sh as shared utilities. Define variable-to-validator mapping using parallel arrays (bash 3.2 compatible). validate_env() checks all ~50 .env variables against their expected format and reports all failures at once. Wired into preflight.sh (Check 6b) and bitwarden_to_env.sh (post-restore). configure_env.sh now sources validators from common.sh instead of defining its own copies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -156,4 +156,15 @@ else
|
||||
fi
|
||||
|
||||
log_success "Restored .env to $OUTPUT_FILE ($field_count variables)"
|
||||
log_warn "Review the file before use — check for placeholder values that may need updating"
|
||||
|
||||
# Validate restored values against expected formats
|
||||
log_info "Validating restored .env values..."
|
||||
set -a
|
||||
# shellcheck source=/dev/null
|
||||
source "$OUTPUT_FILE"
|
||||
set +a
|
||||
if validate_env; then
|
||||
log_success "All .env values pass format validation"
|
||||
else
|
||||
log_warn "Some .env values failed validation — review and fix before running preflight"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user