A simple python validation library.
Project description
Damson: A Concise Python Validation Library™
Damson is a concise python library which aims to simplify the field validation.
Hold your breath! The power of Damson:
import damson
from damson.constraint import (Required, DataType, Between)
@damson.verify(a=[DataType(int,float)], b=[DataType(int), Between(1, 10)])
def add(a, b, ):
return a + b
print(add(2, 3))
try:
add(2, 3.0)
except Exception as e:
print(e)
try:
add(2, 10)
except Exception as e:
print(e)
@damson.verify(**{'name': [Required(), DataType(str)], '0': [Required(), DataType(int)]})
def mix_args(name, *args):
return '%s=%s' % (name, args)
mix_args('stone', 10, 20, 30)
@damson.verify(**{'0': [Required(), DataType(str)], '1': [Required(), DataType(int)]})
def create_kv(*args):
return {args[0]: args[1]}
kv = create_kv('name', 10)
assert kv['name'] == 10
Installation
# Use pip
pip install damson
# Use ananconda
conda install damson
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
damson-0.6.0.tar.gz
(8.7 kB
view hashes)
Built Distribution
damson-0.6.0-py2.py3-none-any.whl
(10.1 kB
view hashes)
Close
Hashes for damson-0.6.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a8418bbd30dd6c5e1951fd74ef9f616b51767604c789df41458b82c68231640 |
|
MD5 | e73fda6fd57c5a0f1c58c01ea5cedbd8 |
|
BLAKE2b-256 | 0a1753fb3591e8237d64efcbf3358c56b256122aaa0eaf18edda7214277387a4 |