Skip to main content

Disinfect: Destroy bad input.

Project description

Disinfect allows you to validate and sanitize incoming data.

A quick example:

import disinfect as d

mapping = d.Mapping({
    'first': d.String(),
    Field('infix', default=''): d.String(min_len=0,
    'last': d.String(),

    'addresses': d.ListOf(Mapping({
        'zipcode': d.String(min_len=5, max_len=5),
        'housenumber': d.Int(min_value=1),

user = mapping({
    'first': 'Nils',
    'last': 'Corver',
    'addresses': [
        {'zipcode': '71486', 'housenumber': '49'},
        {'zipcode': '59546', 'housenumber': '709'},

assert user == {
    'first': 'Nils',
    'infix': '',
    'last': 'Corver',
    'addresses': [
        {'zipcode': '71486', 'housenumber': 49},
        {'zipcode': '59546', 'housenumber': 709},

with raises(d.MultiValueError) as exc:

assert exc.value.to_dict() == {
    'first': 'Field is required.',
    'last': 'Field is required.',
    'addresses': 'Field is required.',


  • TODO


Disinfect is written and maintained by Nils Corver.

A full list of contributors can be found in GitHub’s overview.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Disinfect, version 0.2.1
Filename, size & hash File type Python version Upload date
Disinfect-0.2.1-py2.py3-none-any.whl (7.3 kB) View hashes Wheel py2.py3
Disinfect-0.2.1.tar.gz (14.7 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page