Skip to main content

crashbytes-guard

Expressive guard clauses for Python — fail fast with readable validation.

Install

pip install crashbytes-guard

Usage

from crashbytes_guard import Guard

def create_user(name: str, age: int, email: str) -> None:
    Guard.against_none_or_whitespace(name, "name")
    Guard.against_out_of_range(age, 0, 150, "age")
    Guard.against_invalid_email(email, "email")
    # ...proceed safely

Available Guards

Method Description
against_none(value, name) Rejects None
against_none_or_empty(value, name) Rejects None or ""
against_none_or_whitespace(value, name) Rejects None, "", or whitespace-only
against_empty(value, name) Rejects empty collections/strings
against_negative(value, name) Rejects negative numbers
against_negative_or_zero(value, name) Rejects non-positive numbers
against_zero(value, name) Rejects zero
against_out_of_range(value, min, max, name) Rejects values outside [min, max]
against_invalid_email(value, name) Rejects invalid email format
against_invalid_url(value, name) Rejects non-HTTP(S) URLs
against_predicate(value, pred, name, msg) Rejects when predicate returns True
against_length_out_of_range(value, min, max, name) Rejects strings outside length range
against_type(value, expected, name) Rejects wrong types
against_not_in(value, allowed, name) Rejects values not in allowed set
against_pattern(value, pattern, name) Rejects strings not matching regex

All methods return the validated value for fluent chaining.

License

MIT

Metadata

Release files for crashbytes-guard 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crashbytes-guard 1.0.0
File Size Uploaded
crashbytes_guard-1.0.0.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crashbytes-guard 1.0.0
File Interpreter ABI Platform
crashbytes_guard-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / crashbytes_guard-1.0.0.tar.gz

Download URL crashbytes_guard-1.0.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4cc69860991744c760e3d12b30a301bc186c242cdab8f7e4bd331fae04de0f19
BLAKE2b-256 checksum
How to use checksums
20c82e3fc9eb70e591d4ad279a9d5f94de225d1ee73e264786c55d22e8deb431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 4, 2026.

Transparency log

Release files / crashbytes_guard-1.0.0-py3-none-any.whl

Download URL crashbytes_guard-1.0.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ca12bd2eec0ea20ecea145d2db9b62c3fc7484bf89b9e956546d71e0341a39a
BLAKE2b-256 checksum
How to use checksums
54edb99991ee838d2b2accdf5f4442056ee2f4f0d022bc1df8fe7ee17fe6aa8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page