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, ListNode
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.1.0.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file fractal-input-1.1.0.tar.gz
.
File metadata
- Download URL: fractal-input-1.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2c81c373792a7a2c5baf9ab1a1fefc1b9570de7d2ea72990d9e874aa2d8d383 |
|
MD5 | 5c1899714490c34c6e545a464dae7bcb |
|
BLAKE2b-256 | c0347e18e9fda14ea3f3900e859f1c65c60ae27530d7304e8e6a663acffac7ff |
File details
Details for the file fractal_input-1.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: fractal_input-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c6a29a729bca438433f682a0d774173bde2774beef09c03cebea589c7e41dfc |
|
MD5 | fb73da348177a826825116ff7ec28a92 |
|
BLAKE2b-256 | 45d49799e5b76d5e24154bd1ededd4771b09fdd676df3825bdf1b9a7abe7ee9c |