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.1.2.tar.gz
(17.8 kB
view details)
Built Distribution
File details
Details for the file onecondition-1.1.2.tar.gz
.
File metadata
- Download URL: onecondition-1.1.2.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c6e4bcc964dd20f94be01e7ddc48de3289e603d7cac88f6684ff84bf2e5f884 |
|
MD5 | 70c734b4349894ef69a6f3473f64f54e |
|
BLAKE2b-256 | e7b4c1eee5b7c1c5132a4bde8b517ff92bce2c8cd13ca5d411ebab6811964c92 |
File details
Details for the file onecondition-1.1.2-py3-none-any.whl
.
File metadata
- Download URL: onecondition-1.1.2-py3-none-any.whl
- Upload date:
- Size: 18.4 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 | 06273405abdaeb5ac9766415bdc5b0d160c0a82c6fd63eb34a04c58522eb6eb8 |
|
MD5 | 0d0666c6ceb03c6408fdeb33c009ee57 |
|
BLAKE2b-256 | 65b3762e2bb34be169c106d8a1e3eb9fc9919e9293a0743bde95756514e65d91 |