Skip to main content

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

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.1.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

pyow-0.0.1-py3-none-any.whl (21.9 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