Skip to main content

data validation and conversion library

Project description

PyDto is a data conversion library. It can validate data, that comes from various data serialization formats like JSON, YAML, etc. and convert it to native Python datatypes. It can also convert native Python objects to described DTO.

A taste of this library:

>>> schema = Schema({
...     Required('someString1', 'some_string_1'): String(),
...     Optional('someString2', 'some_string_2'): String(),
...     Required('someDict', 'some_dict'): {
...         Required('someInt', 'some_int'): Integer(),
...         Required('someList', 'some_list'): List(Decimal()),
...         Required('someOtherList', 'some_other_list'): List({
...             Required('innerString', 'inner_string'): String(),
...             Required('innerInt', 'inner_int'): Integer()
...         })
...     }
... })
>>> native_object = schema.to_native({
...     'someString1': 'asdf',
...     'someDict': {
...         'someInt': 2,
...         'someList': ['11.5', '12.2'],
...         'someOtherList': [
...             {'innerString': 'is1', 'innerInt': 1},
...             {'innerString': 'is2', 'innerInt': '2'}
...         ]
...     }
... })
>>> assert native_object == {
...     'some_string_1': 'asdf',
...     'some_dict': {
...         'some_int': 2,
...         'some_other_list': [
...             {'inner_int': 1, 'inner_string': 'is1'},
...             {'inner_int': 2, 'inner_string': 'is2'}
...         ],
...         'some_list': [decimal.Decimal('11.5'), decimal.Decimal('12.2')],
...     }
... }

Check out documentation for more detailed review at Github repo.

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

pydto-0.4.0.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file pydto-0.4.0.tar.gz.

File metadata

  • Download URL: pydto-0.4.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pydto-0.4.0.tar.gz
Algorithm Hash digest
SHA256 09b46c360df69e705c2fca0a898e4a9c2e754e803ccaff6d13d236da0d829b66
MD5 a1fd108327e646d3f2121779502a4321
BLAKE2b-256 fcd6f541f9bdc24d88bfce399109159f9711243623ffb1b63e98f0ab12909692

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page