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.4.tar.gz (41.8 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.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crashbytes_envguard-1.1.4.tar.gz
  • Upload date:
  • Size: 41.8 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.4.tar.gz
Algorithm Hash digest
SHA256 cf842dac08c3d370348832db1a898003ea8d9807cbd8bf1af2012bc3b1b85de6
MD5 a1468f87c080e3e19ddf5c520160e48a
BLAKE2b-256 90c118c0d3415d8680b7a32de0bb1a68b55bbbff93822421ff2c565105dea448

See more details on using hashes here.

Provenance

The following attestation bundles were made for crashbytes_envguard-1.1.4.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.4-py3-none-any.whl.

File metadata

File hashes

Hashes for crashbytes_envguard-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 73f0a52f4b8ae9de3ee37f26b11827a7a908f6a109f717087acf73210528f9a5
MD5 d00d19bec0a0e0dfbf7661afebf55f74
BLAKE2b-256 c83cdd149d731fd629f49c52a18adb0831922e5a4a99f27e300d3315f9623894

See more details on using hashes here.

Provenance

The following attestation bundles were made for crashbytes_envguard-1.1.4-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