Skip to main content

PGV for python via just-in-time code generation

Project description

Protoc-gen-validate (PGV)

While protocol buffers effectively guarantee the types of structured data, they cannot enforce semantic rules for values. This package is a python implementation of protoc-gen-validate, which allows for runtime validation of various semantic assertions expressed as annotations on the protobuf schema. The syntax for all available annotations is in validate.proto. Implemented Python annotations are listed in the rules comparison.

Example

from entities_pb2 import Person
from protoc_gen_validate.validator import validate, ValidationFailed, validate_all

p = Person(name="Foo")
try:
    validate(p)
except ValidationFailed as err:
    print(err)  # p.id is not greater than 999
    
try:
    validate_all(p)
except ValidationFailed as err:
    print(err)  
    # p.id is not greater than 999
    # p.email is not a valid email
    # p.name pattern does not match ^[A-Za-z]+( [A-Za-z]+)*$
    # home is required.

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

protoc_gen_validate-1.2.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

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

protoc_gen_validate-1.2.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file protoc_gen_validate-1.2.1.tar.gz.

File metadata

  • Download URL: protoc_gen_validate-1.2.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.12.0 requests/2.32.3 setuptools/70.0.0 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.9.5

File hashes

Hashes for protoc_gen_validate-1.2.1.tar.gz
Algorithm Hash digest
SHA256 62cd74043e49a34346a3fe7a7fe39e8adce69b19edc99b4d8d410c02a727d552
MD5 f94431ffe1ece57570dd77fd6c32b5d5
BLAKE2b-256 31eabf9e78c25b71205d2f194d8c4ce0c0adabea12bbe810eb0aa3c7ec62fee5

See more details on using hashes here.

File details

Details for the file protoc_gen_validate-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: protoc_gen_validate-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.12.0 requests/2.32.3 setuptools/70.0.0 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.9.5

File hashes

Hashes for protoc_gen_validate-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f52989e2f0fd60f140ce55ebe7d361291dd31626ecba2ce8eb4605b7413d393
MD5 f2d795134150cd7a4df9dc2c40f3bc76
BLAKE2b-256 e6df3fc3b425c8304b117164fd4f3ccdd2327e7a13f809bd7b43b633a59569df

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