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.0.tar.gz
(18.0 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-0.10.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ffd34452a00a063637886403909c8e8c2545023e93ce98135369860158ffcd4 |
|
MD5 | 5c8ebaa3a5d099a690907ad03c99605e |
|
BLAKE2b-256 | 38df014c415417117d2f125317f7f1490759287f750bbb88f1a75ec29a10d629 |
Close
Hashes for protoc_gen_validate-0.10.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0f2efe5521285b603b36a92450b2d6218d7c7e4aff3f906a330268a596235c0 |
|
MD5 | df9e28927ea1e487e3689f932f6c4228 |
|
BLAKE2b-256 | e4746ba8836c5bb078cd252afa768051c6bf0b9ca4eb7d47fc55ada78ec67eb0 |