Skip to main content

Abstracts HTTP request input handling, providing an easy interface for data hydration and validation

Project description

Build Status Version Pyversions

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']

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fractal_input, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size fractal_input-1.0.2-py2.py3-none-any.whl (5.0 kB) File type Wheel Python version 3.7 Upload date Hashes View
Filename, size fractal_input-1.0.2.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page