Conditions-PY
Conditions is a Python port of the famous .NET library Conditions which helps developers write pre- and postcondition validations in a fluent manner. Writing these validations is easy and it improves the readability and maintainability of code.
Contents
Installation
Installation is done via PIP:
pip install conditions-py
Conditions
A full list of all the available conditions can be found in the Wiki.
Tests
Currently both unit and integration tests are written using the pytest library. Execution of tests in Visual Studio Code is performed using the pytest test runner.
Examples
import conditions_py
def speak(message: str):
Condition\
.requires_str(message, 'message')\
.is_not_null_or_whitespace()
# Do speaking...
def multiple(left: int, right: int):
Condition\
.requires_num(left, 'left')\
.is_positive()
Condition\
.requires_num(right, 'right')\
.is_greater_than(4)
# Do multiplication
def is_true(value: bool):
Condition\
.requires_bool(value, 'value')\
.is_true()
# Do other stuff
def animals(dog: object, cat: object):
Condition\
.requires_obj(dog, 'dog')\
.is_not_null()
Condition\
.requires_obj(cat, 'cat')\
.is_null()
# Do other stuff
A particular validation is executed immediately when it's method is called, and therefore all checks are executed in the order in which they are written:
Acknowledgements
- The icon "Tornado" designed by Adam Whitcroft from The Noun Project.
- Geoffrey Huntley (ghuntley) who is the original author of "Conditions" from which this project was based on.
Metadata
Release files for conditions-py 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| conditions_py-0.1.7.tar.gz | 6.2 kB | Without provenance | Details for conditions_py-0.1.7.tar.gz |
Release files / conditions_py-0.1.7.tar.gz
| Download URL | conditions_py-0.1.7.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b64c0e5e36beda6cb98e975fe6fe406a45c4312309e42f3983876dcae7472d9
|
|
BLAKE2b-256 checksum How to use checksums |
bd5b4cb350bcfed96a434915472e021b99ca07c792796eb5a8aff73468d4063a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4
|
Security for conditions-py 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.