A validation library for python using trafaret
Project description
Install:
pip install trafaret_validator
This is a wrapper that validate params using Trafaret ( http://trafaret.readthedocs.org/en/latest/ ).
Usage:
import trafaret as t
from trafaret_validator import TrafaretValidator
def foo_validator(value):
if value != 'foo':
return t.DataError('Expected foo!')
return 'foo'
class RequestValidator(TrafaretValidator):
ids = t.List(t.Int)
payload = t.Dict(foo=t.Call(foo_validator))
validator = RequestValidator(ids=ids, payload=payload)
if not validator.validate():
return validator.errors
data = validator.data # returns checked dict of params {'ids': [...], 'payload': {'foo': 'foo'}}
ids = validator.ids
payload = validator.payload
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
File details
Details for the file trafaret_validator-0.4.0.tar.gz
.
File metadata
- Download URL: trafaret_validator-0.4.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 321e32d9a79cce82dcccca06e5bb95a82b76eb93a1bce647917878a0b59818d2 |
|
MD5 | 2cf74662fb64a060af92e4214046afdd |
|
BLAKE2b-256 | c7a204215bcf2e0dbe68a28e1323b1341246b9393dd27aa1398f2e0c3a4cd5e5 |