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.2.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.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crashbytes_envguard-1.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 220f16f34712ce1fc84f6a0763677390115d4b68aca2904c2751b8b5d05f4ce7
MD5 4020489cf4c9169a2dc6795b3278deae
BLAKE2b-256 bfa9a92d0e38c430751a6b7248eea92f44f238f2edae7b9581b053f14b07e268

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for crashbytes_envguard-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0ac6c726ad8a8cea94f8e39b9bc72590a7a1695616eedf38cc0c7eb2ea106926
MD5 5ef42e0ce72755e8ebb2f8b8c56b8695
BLAKE2b-256 ecb4e345588fd579ceb103d551217f74ea6e7c17b5e803c741b37ac4f0aab8ae

See more details on using hashes here.

Provenance

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