An ultra-lightweight package for validating single conditions.
Project description
1️⃣ OneCondition
An ultra-lightweight package for validating single conditions.
Usage
>>> import onecondition as oc
>>> def inverse(user_input):
... oc.validate.instance(user_input, (int, float))
... oc.validate.positive(user_input)
... return 1 / user_input
>>> inverse(4)
0.25
>>> inverse(0)
Traceback (most recent call last):
...
onecondition.ValidationError: Value `0` must be positive (non-zero)
>>> inverse("foobar")
Traceback (most recent call last):
...
onecondition.ValidationError: Value `'foobar'` must be an instance of (<class 'int'>, <class 'float'>), not a <class 'str'>
Full Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
onecondition-1.0.13.tar.gz
(17.6 kB
view details)
Built Distribution
File details
Details for the file onecondition-1.0.13.tar.gz
.
File metadata
- Download URL: onecondition-1.0.13.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55ba8980adac125f8f383f2400487d1886788218ce29d167ac2d84154bdd6374 |
|
MD5 | a3463e5427875d8fda78d69e5b3cb2e3 |
|
BLAKE2b-256 | 2d7e64b48545ce3c4d3e84827c8b6034499870938f451f47f8b1eccdea55dcb7 |
File details
Details for the file onecondition-1.0.13-py3-none-any.whl
.
File metadata
- Download URL: onecondition-1.0.13-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b43a60933a8a75ac8c33a05a9d66a30b9657a8075c439014b9afb30c2184d053 |
|
MD5 | a9e0acf4beaba4b2e6c8690a6993d665 |
|
BLAKE2b-256 | fb877d535fe102423e5b7b78e77b7c9025544b6b76a00160dc41e0c8301c9953 |