Skip to main content

A yaml like schema that can be used to check dictionaries for correct schema

Project description

typeschemalib

A yaml like schema that can be used to check dictionaries for correct schema

Schema file

schema example

point: Int
my_string: Str
grade: Float

data example

{"point": 45, "my_string": "Hey", "grade": 4.5}

Checking data for correct schema

from typeschemalib import typeschemalib

# Set schema file
schema_file = "test.stml"
# Set Data dictionary that corresponds to schema file
data = {"point": 45, "my_string": "Hey", "grade": 4.5}

# Check data for correct schema_file
data_checker = typeschemalib.DataChecker(schema_file, data)

# Run type check to see if data corresponds
# valid will be True if schema is correct, it will throw errors otherwise
valid = data_checker.check_type()

Todo

Make schema have regex Make schema have functions or options to validate data

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

typeschemalib-0.7.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

typeschemalib-0.7-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

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