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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file damson-0.6.0.tar.gz.

File metadata

  • Download URL: damson-0.6.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/2.7.16

File hashes

Hashes for damson-0.6.0.tar.gz
Algorithm Hash digest
SHA256 0b55defcf06256ded1208e9ba6036ffe01568e4ebb36b8a675aeb975af6d1718
MD5 ae78ced68e239e2928376d5ddc6eb3c3
BLAKE2b-256 f7255834e289ba62ec4282d0778a56f4f550a3743bcd0d3a66f4981e92bcce47

See more details on using hashes here.

File details

Details for the file damson-0.6.0-py2.py3-none-any.whl.

File metadata

  • Download URL: damson-0.6.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/2.7.16

File hashes

Hashes for damson-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9a8418bbd30dd6c5e1951fd74ef9f616b51767604c789df41458b82c68231640
MD5 e73fda6fd57c5a0f1c58c01ea5cedbd8
BLAKE2b-256 0a1753fb3591e8237d64efcbf3358c56b256122aaa0eaf18edda7214277387a4

See more details on using hashes here.

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