Skip to main content

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

onecondition on Read the Docs

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

onecondition-1.0.2.tar.gz (16.8 kB view hashes)

Uploaded Source

Built Distribution

onecondition-1.0.2-py3-none-any.whl (18.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page