Skip to main content

Introducing Python Data Contracts

With this package you can define your own data contracts strictly and define data validations and pre-processing steps which will insure data integrity and capable of serializing to-and-from JSON format.

Example Usage

from serializer import Interface
class IP(Interface):

    # Declaring data type validations
    ip_address = str
    host_name = str

class Record(Interface):
    user_name = str
    age = int
    ip = IP

    # Pre-processors to standardize data
    def __user_name__(value):
        return value.capitalize()

args = {
    'user_name': 'ximi', 
    'age': 21, 
    'ip': IP(ip_address='192.168.2.1', host_name='localhost')
    }
request = Record(**args)
print ("Serializing from Object to JSON: \n", request.serialize())
# Serializing from Object to JSON:  
# {'user_name': 'Ximi', 'age': 21, 'ip': {'ip_address':'192.168.2.1', 'host_name': 'localhost'}}
args = {
    'user_name': 'ximi', 
    'age': 21, 
    'ip': {
        'ip_address': '192.168.2.1',
        'host_name': 'localhost'
        }
    }
request = Record(**args)
print ("Serialise with Reverse type conversion: \n", request.serialize())
# Serialise with Reverse type conversion: 
# {'user_name': 'Ximi', 'age': 21, 'ip': {'ip_address': '192.168.2.1', 'host_name': 'localhost'}}

Download files

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

Source Distribution

python-serializer-1.0.2.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_serializer-1.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file python-serializer-1.0.2.tar.gz.

File metadata

  • Download URL: python-serializer-1.0.2.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2

File hashes

Hashes for python-serializer-1.0.2.tar.gz
Algorithm Hash digest
SHA256 dbd3887bd51495fb66c710e443a6a6e2d98a220a8c4f7f69affaa9299b8ee26a
MD5 6a57e842f4846d0069b38775b680a8ca
BLAKE2b-256 e63bb743be01643e8b9f6a114c24b3e6e9f6a6124caa1ba8a57b9564facf948b

See more details on using hashes here.

File details

Details for the file python_serializer-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: python_serializer-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.2

File hashes

Hashes for python_serializer-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5677e75055a4de5e2c46701daa3f41bcaeac5d196727f9fd091c4d32b6910d8d
MD5 8ad1b1863399d3b39bf9e42d9aed76c1
BLAKE2b-256 cca65fc4b64ef0ea635ada684029f845e2bd24582d1bf4ce15636b7b797b7204

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page