Skip to main content

Anonymous datatype validation

Project description

For full package documenation, please see: http://datatype.readthedocs.org/

Examples

>>> from datatype.validation import failures

>>> datatype = {'foo': [{'bar': 'int'}]}
>>> bad_value = {'foo': [{'bar': 'baz'}], 'bif': 'pow!'}

>>> failures(datatype, bad_value)
['unexpected property "bif"', 'foo[0].bar: expected int, got str']

Wildcard dictionary keys:

>>> datatype = {'_any_': ['int']}
>>> good_value = {'foo': [1, 2, 3], 'bar': [3, 4, 5]}

>>> failures(datatype, good_value)
[]

Coercion:

>>> from datatype.coercion import coerce_value

>>> coerce_value(['str'], [1, 2, 3])
['1', '2', '3']

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

datatype-0.8.3.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file datatype-0.8.3.tar.gz.

File metadata

  • Download URL: datatype-0.8.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for datatype-0.8.3.tar.gz
Algorithm Hash digest
SHA256 98a273d3db7b0a0c1f867b2721b1aaa1e128ac01bae1e7eea9b0e3ab2137ac8c
MD5 47cac1c84725c0904186dfdd4e41c571
BLAKE2b-256 d4dfcf8ba667c2402d19c6b8f633e7116ff9d583401d3b4467ddad3d383b0341

See more details on using hashes here.

Supported by

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