Overview
Theenv_vars section checks for the presence of environment variables and optionally validates their values against regex patterns. This ensures critical configuration values are set before running your application.
Configuration
Each environment variable check is defined by anEnvVarCheck struct (src/config.rs:31) with the following fields:
The name of the environment variable to check.
Whether the environment variable must be set. If
true, validation fails when the variable is not defined.A regex pattern to validate the variable’s value. If specified, the value must match this pattern.
Examples
Basic Presence Check
Check that an environment variable is set:Optional Variables
Mark variables as optional when they have sensible defaults:Pattern Validation
Validate that environment variable values match expected formats:Real-World Examples
Pattern Syntax
Thepattern field uses standard regex syntax. Here are common patterns:
Exact Values
Boolean Values
Numeric Ranges
URL Validation
Custom Formats
Remember to escape backslashes in YAML strings. Use
\\ for a single backslash in regex patterns.Default Behavior
From the struct definition in src/config.rs:31:name: Required field, no defaultrequired: Defaults totruepattern: Defaults toNone(no pattern validation)
