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.3.3.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.3.3-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: protoc_gen_validate-1.3.3.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for protoc_gen_validate-1.3.3.tar.gz
Algorithm Hash digest
SHA256 76c1cea6c2b1290fc2a266b7d19f44cdcc1dc496236b760db1a50e1672d6c978
MD5 2d15fe627bff7240939d5ee4c5597e53
BLAKE2b-256 8efc24e9345f017d3e9d7fe2a9faa89fc973db7b3ccaecd54815cb6ee46c49d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for protoc_gen_validate-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 da57131e2315f2b40a5ad4c75ce5352dbd8edc18a0787557895e1ebd2d74b883
MD5 6453e18d983508820394b28aafa9f3a7
BLAKE2b-256 71d047aee72553d71e142418aa89da128ae9cd1dcb57fafea56832641d05a97d

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