Skip to main content

Validate CBOR documents using CDDL schema language

Project description

PyCDDL: A CDDL validation library for Python

CDDL is a schema language for the CBOR serialization format. pycddl allows you to validate CBOR documents match a particular CDDL schema, based on the Rust cddl library.

For example, here we use the cbor2 library to serialize a dictionary to CBOR, and then validate it:

from pycddl import Schema
import cbor2

uint_schema = Schema("""
    object = {
        xint: uint
    }
"""
)
uint_schema.validate_cbor(cbor2.dumps({"xint", -2}))

If validation fails, a pycddl.ValidationError is raised.

Release notes

0.2.0

  • Schemas are now only parsed once (when the Schema() object is created), instead of every time validation happens, which should improve validation performance.
  • Updated to a newer version of underlying CDDL library, which should make CDDL parsing more compliant.
  • Added a repr() implementation to Schema for easier debugging.

0.1.11

  • Initial release.

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

pycddl-0.2.0.tar.gz (14.8 kB view hashes)

Uploaded Source

Built Distributions

pycddl-0.2.0-cp37-abi3-win_amd64.whl (1.0 MB view hashes)

Uploaded CPython 3.7+ Windows x86-64

pycddl-0.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.7+ manylinux: glibc 2.17+ x86-64

pycddl-0.2.0-cp37-abi3-macosx_10_7_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7+ macOS 10.7+ x86-64

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