Abstracts HTTP request input handling, providing an easy interface for data hydration and validation
Project description
Abstracts HTTP request input handling, providing an easy interface for data hydration and validation Based on https://github.com/LinioIT/input
Documentation
Usage
Install:
$ pip install fractal_input
from fractal_input import InputHandler, DatetimeNode, Telephone
class UserHandler(InputHandler):
def define(self):
user = self.add('user', User)
user.add('name', 'string')
user.add('email', 'string')
user.add('age', 'integer', {'required': False})
user.add('createdAt', DatetimeNode('%m/%d/%y %H:%M:%S'))
address = user.add('address', Address)
address.add('street', 'string')
telephone = user.add('telephones', ListNode(Telephone))
telephone.add('number', 'string')
dict_data = {
'user': {
'name': 'James',
'email': 'james@email.com',
'age': 20
}
}
input = UserHandler()
input.bind(dict_data)
if not input.is_valid():
print(input.get_error_as_string())
user = input.get_data()['user']
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
fractal_input-1.0.0.tar.gz
(4.5 kB
view hashes)
Built Distribution
Close
Hashes for fractal_input-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d5a3f2dd1cd50921a09f4b45a0551ffe56319819b75a0a6688dfb263436f06f |
|
MD5 | c212c50bee345f896376e716dd66b981 |
|
BLAKE2b-256 | fa0060e837a70efa2eea9fd103a44072f4c23ea63af01217a7671322f3304b0f |