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 ^[^[0-9]A-Za-z]+( [^[0-9]A-Za-z]+)*$
# home is required.
Project details
Release history Release notifications | RSS feed
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-0.10.1.tar.gz
(18.0 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-0.10.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5084ecf416bae6995b16dcc3cee51f02f466ca7366c70c85a38efb6cf054a478 |
|
MD5 | 2faebd6d5cc02c3b2b958d6ff041bff5 |
|
BLAKE2b-256 | a26c9e906786933bf4bfdb635fa81825685c4b29176b7fcf9d0792f24dde1e06 |
Close
Hashes for protoc_gen_validate-0.10.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21278ef9550b917668dd0e050f9c5aa805d0c0abc52c6b1fd5576a8835a8a53e |
|
MD5 | 61663a4653e55a69f53f033226f09a2a |
|
BLAKE2b-256 | 1f9963f9e8aeec2a7db2665d64f8c5f6eea346de668877da332ccbe149653d7a |