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

Uploaded Python 3

File details

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

File metadata

  • Download URL: crashbytes_envguard-1.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2f5e83b48fe0e8ce95a5d602a270b4ab0e885d2cefd94b4a8eb5eb8a444bd8ff
MD5 2acdbbe0c405c0804b45b8081b412681
BLAKE2b-256 a62e928f948fab8111f1d21aa8964c86a35cb75bb987e64fd60cbfd03b689bf3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for crashbytes_envguard-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 57dd63a734017bd42a5989cc88b95952872fa4b1c023603d28ffc8fdd7738163
MD5 ec626cc9797cf5b00f1df0c02c1418a7
BLAKE2b-256 0e7ea1b4219fa657a6053019e78bf80d01e2368c12d01881972ca6f731df3b76

See more details on using hashes here.

Provenance

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