Disinfect: Destroy bad input.
Project description
Disinfect allows you to validate and sanitize incoming data.
Free software: MIT license
Documentation: http://pythonhosted.org/disinfect
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
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.0.tar.gz
(14.5 kB
view hashes)
Built Distribution
Close
Hashes for Disinfect-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9152298f315769517e7a4fcb397db3fa87cf74abc116fb7179b361dc65ee528e |
|
MD5 | 06535d162006b113585fa0e624020919 |
|
BLAKE2b-256 | cc79baf1959240a0e2a7d6940495fc816503ae5cea12a00642acb61ceb2cfd44 |