Skip to main content

Lightweight environment variable validation with schema, type coercion, and .env loading.

Project description

crashbytes-envguard

Lightweight environment variable validation with schema, type coercion, and .env loading.

Install

pip install crashbytes-envguard

Usage

from crashbytes_envguard import create_env, s

env = create_env({
    "PORT": s.port().default(8080),
    "DB_URL": s.url(),
    "DEBUG": s.boolean().default(False),
    "LOG_LEVEL": s.string().choices("debug", "info", "warn", "error").default("info"),
})

print(env["PORT"])      # 8080 (int, type-coerced)
print(env["DB_URL"])    # "https://..." (validated)
print(env["DEBUG"])     # False (bool, type-coerced)

Fails fast with all errors at once:

EnvError: Environment validation failed:
  - DB_URL: required but not set
  - PORT: must be >= 1 (got 0)

Schema Types

Builder Type Extra Validation
s.string() str
s.integer() int
s.number() float
s.boolean() bool true/1/yes/on, false/0/no/off
s.port() int 1–65535
s.url() str Must start with http(s)://
s.email() str Must be valid email format

Field Modifiers

.default(value), .optional(), .choices(...), .min(n), .max(n), .pattern(regex)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crashbytes_envguard-1.1.3.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crashbytes_envguard-1.1.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file crashbytes_envguard-1.1.3.tar.gz.

File metadata

  • Download URL: crashbytes_envguard-1.1.3.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for crashbytes_envguard-1.1.3.tar.gz
Algorithm Hash digest
SHA256 c7b27bff58ded3edca5d4b4709eb7636c3abe466dfc5db4eac49c57c37afb781
MD5 06caf3bd7781e3b782c4a2b325afbb52
BLAKE2b-256 7fcde50e625a20568360ec4e67618d55966518beb0158a46e8a64a79b5b5e3a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for crashbytes_envguard-1.1.3.tar.gz:

Publisher: publish.yml on CrashBytes/crashbytes-envguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crashbytes_envguard-1.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for crashbytes_envguard-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f7fb5aaa86aea2ba43f59802e5df37ff6018ffc323a99e659e807aa51258f4d
MD5 df4c1bca467abc18af6e574a6f0e95a0
BLAKE2b-256 067b0df8473354bac871374453fd49983213621d7472e3d70d7250a5f5f22780

See more details on using hashes here.

Provenance

The following attestation bundles were made for crashbytes_envguard-1.1.3-py3-none-any.whl:

Publisher: publish.yml on CrashBytes/crashbytes-envguard

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page