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

Uploaded Python 3

File details

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

File metadata

  • Download URL: crashbytes_envguard-1.1.0.tar.gz
  • Upload date:
  • Size: 6.3 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.0.tar.gz
Algorithm Hash digest
SHA256 326ebe5f6d95ade700aaa170cddeaed8bbc66013b8283c80a8851d093bcefa41
MD5 e45b3c6966697ecaa3d6bd7e3b29b3f0
BLAKE2b-256 32b1b31a2bfd2a56d4a9fba7d7a9c3c240e9051737534ecf5e8aa8301f8810bc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for crashbytes_envguard-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41a54b5d797f3ed34d82206f5168d727efbc50d7c740d3c38170526517b5aaa0
MD5 416910bd3968afa9cbd97b21ce4fede5
BLAKE2b-256 665e95caf1c22f07219be9c76dbfcf95db48e437e9f667ab532bee73b6a45e92

See more details on using hashes here.

Provenance

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