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,
                                         max_len=40),
    '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:
    mapping({})

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

Features

  • TODO

Authors

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.

Source Distribution

Disinfect-0.2.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

Disinfect-0.2.1-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Disinfect-0.2.1.tar.gz.

File metadata

  • Download URL: Disinfect-0.2.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Disinfect-0.2.1.tar.gz
Algorithm Hash digest
SHA256 721baa30cf9bc05130f01ed7bd5f917ff0f201e9c1903204187739a82014c310
MD5 25c4b05867e507c762247a4dd5ad422e
BLAKE2b-256 112787c79f2e4415feaffb9e2da96b26f273f54a2a548a3ed03d23d86e915898

See more details on using hashes here.

File details

Details for the file Disinfect-0.2.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Disinfect-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2590c6786580746c3fd18bbb977b98d212e1653f51acc878337720778b0f4b95
MD5 1e179d3a755ca60c4c53d7e84cf3ea8e
BLAKE2b-256 b4d132c332377471252d9239dda64d2824cca44c13d9b0bed537f0f9f9a08b40

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