Skip to main content

Schemas for data structures.

Documentation

This README has some basic usage information, but more detailed documentation may be found at ReadTheDocs.

Usage Example

First, install it from PyPI.

pip install validator.py
from validator import Required, Not, Truthy, Blank, Range, Equals, In, validate

# let's say that my dictionary needs to meet the following rules...
rules = {
    "foo": [Required, Equals(123)],
    "bar": [Required, Truthy()],
    "baz": [In(["spam", "eggs", "bacon"])],
    "qux": [Not(Range(1, 100))] # by default, Range is inclusive
}

# then this following dict would pass:
passes = {
    "foo": 123,
    "bar": True, # or a non-empty string, or a non-zero int, etc...
    "baz": "spam",
    "qux": 101
}
print validate(rules, passes)
# (True, {})

# but this one would fail
fails = {
    "foo": 321,
    "bar": False, # or 0, or [], or an empty string, etc...
    "baz": "barf",
    "qux": 99
}
print validate(rules, fails)
# (False,
#  {
#  'foo': ["must be equal to '123'"],
#  'bar': ['must be True-equivalent value'],
#  'baz': ["must be one of ['spam', 'eggs', 'bacon']"],
#  'qux': ['must not fall between 1 and 100']
#  })

Metadata

Release files for validator.py 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for validator.py 1.3.0
File Size Uploaded
validator.py-1.3.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for validator.py 1.3.0
File Interpreter ABI Platform
validator.py-1.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.5 kB

Release files / validator.py-1.3.0.tar.gz

Download URL validator.py-1.3.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ab3b631630bcbc9b77735e81f7fd11fb20d31eab32ad74d3cdac2ba6e138037e
BLAKE2b-256 checksum
How to use checksums
20fb546ac431d08ea860f66ad4862c87f5ef0bc89485100ee63f82faf5480925
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

Release files / validator.py-1.3.0-py2.py3-none-any.whl

Download URL validator.py-1.3.0-py2.py3-none-any.whl
Size 8.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1bb388c6228e9cea665bd879372e44842baf63dda0751a99989068e4ac61ba21
BLAKE2b-256 checksum
How to use checksums
b379d6e61f6876be260d1bd17fe58f11a1219196b15bfd67eb0939650e0680c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.5

3 release files

1.2.4

2 release files

1.2.3

1 release file

1.2.2

1 release file

1.2.0

2 release files

1.1.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.1

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page