A function argument validation for humans
Project description
Function argument validation for humans for Python 3!
Highlights
- Straight port from the amazing library
ow
from Sindre Sorhus - Expressive chainable API
- Lots of built-in validations
- Supports custom validations
- Written in Python3 with Type hinting
Notes
Since this is a straight up port from the JavaScript library not all features are available. Partly since this is a port and I haven't caught up and also since Python doesn't support all usecases as JavaScript does.
Install
$ pip3 install pyow
Usage
from pyow import pyow;
def unicorn(input):
pyow(input, pyow.string.min_length(5));
# …
unicorn(3)
>>> ArgumentError: ('Expected argument to be of type `str` but received type `int`')
unicorn('yo');
>>> ArgumentError: ('Expected string to have a minimum length of `3`, got `yo`'
API
ow(value, predicate)
Test if value
matches the provided predicate
. Throws an ArgumentError
if the test fails.
ow.{type}
All the below types return a predicate. Every predicate has some extra operators that you can use to test the value even more fine-grained.
Primitives
Built-in types
Maintainers
Related
- @sindresorhus/ow - Function argument validation for humans
License
MIT
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
pyow-0.0.2.tar.gz
(9.1 kB
view hashes)
Built Distribution
pyow-0.0.2-py3-none-any.whl
(23.0 kB
view hashes)