Webster is a self validating dict object for python.
Project description
Webster
=======
Webster is a self validating dict object for python.
It expands upon dict's capability by allowing you to pass in a validation
dict object with either types or regular expression values.
Then you can use it for validation by using it as a condition or get
back a detailed error response.
import Webster
# create a schema
schema = {'amount': '([+-]?\\d*\\.\\d+)(?![-+0-9\\.])',
'credit_card': {
'number': '((?:(?:\\d{4}[- ]){3}\\d{4}|\\d{16}))(?![\\d])',
'expiration_date': '((?:(?:0[1-9])|(?:1[0-2]))\\/(?:\\d{2}))(?![\\d])'}
}
# create the object and pass the schema into the init
im_a_dict = Webster(schema)
# add your values
im_a_dict['amount'] = '1.00'
im_a_dict['credit_card'] = {}
im_a_dict['credit_card']['number'] = '4111111111111111'
im_a_dict['credit_card']['expiration_date'] = '05/12'
# lets see if we are valid or not
print im_a_dict.is_valid()
=======
Webster is a self validating dict object for python.
It expands upon dict's capability by allowing you to pass in a validation
dict object with either types or regular expression values.
Then you can use it for validation by using it as a condition or get
back a detailed error response.
import Webster
# create a schema
schema = {'amount': '([+-]?\\d*\\.\\d+)(?![-+0-9\\.])',
'credit_card': {
'number': '((?:(?:\\d{4}[- ]){3}\\d{4}|\\d{16}))(?![\\d])',
'expiration_date': '((?:(?:0[1-9])|(?:1[0-2]))\\/(?:\\d{2}))(?![\\d])'}
}
# create the object and pass the schema into the init
im_a_dict = Webster(schema)
# add your values
im_a_dict['amount'] = '1.00'
im_a_dict['credit_card'] = {}
im_a_dict['credit_card']['number'] = '4111111111111111'
im_a_dict['credit_card']['expiration_date'] = '05/12'
# lets see if we are valid or not
print im_a_dict.is_valid()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for Webster-0.3.dev7.g622a542.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a351ed31b30a1f8c49cc76023ce36444775458fbe76655b0702260e7c577b6b5 |
|
MD5 | 07c4b00da771ad2b6af966726316f5c0 |
|
BLAKE2b-256 | 6e2042b602bed4236ac4176d15a41896b6b9bcabd02b92b0cbe9e2e351793e8f |