Skip to main content

A simple python validation library.

Project description

Damson: A Concise Python Validation Library™

image image image image

Damson is a concise python library which aims to simplify the field validation.

image

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 

image

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)

Uploaded Source

Built Distribution

damson-0.6.0-py2.py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 2 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