Skip to content

A strict, zero-boilerplate env manager with dotenvy support and validation.

License

Notifications You must be signed in to change notification settings

canmi21/envflag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Envflag

A strict, zero-boilerplate environment variable manager with .env support and validation.

envflag enforces a disciplined approach to configuration: you must explicitly initialize the library (which loads .env files via dotenvy), and then query typed values through a validated builder API or simple convenience functions.

Features

  • Strict Initialization: All queries panic if init() has not been called — no silent misconfiguration.
  • Dotenv Support: Seamlessly loads .env files upon initialization, or from a custom path.
  • Prefix Filtering: Keep only environment variables matching configured prefixes (e.g. APP_, SVC_).
  • Validated Builder API: Chain .default(), .validate(), and .get() for type-safe, validated lookups that return Result.
  • Built-in Validators: is_port, is_integer, is_positive_integer, is_positive_number, is_bool, is_non_empty, is_url, is_integer_in_range, and more.
  • Custom Validators: Pass any Fn(&str) -> bool closure as a validator.
  • Zero Boilerplate: No built-in logging or printing; you control how to display your config.

Usage Examples

Check the examples directory for runnable code:

Installation

[dependencies]
envflag = { version = "0.1", features = ["full"] }

Feature Flags

Feature Description
url Enables strict URL validation in is_url via the url crate (WHATWG URL Standard).
regex Enables matches_regex validator via fancy-regex.
tracing Enables optional tracing::warn on validation failures and parse fallbacks in convenience API.
full Enables all features above.

License

Released under the MIT License © 2026 Canmi

About

A strict, zero-boilerplate env manager with dotenvy support and validation.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages