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-1.0.2.tar.gz
(18.1 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec9779f04cf50fef5503f346ecd8fe8d97bc48c85bf6a17ff18a0506de933709 |
|
MD5 | e0cdd5a4b24df1812537bb95496e349d |
|
BLAKE2b-256 | fef35f63c8d6c81f195fff31b392542bf37a931dd9bbbfd87e1331d98b7223b8 |
Close
Hashes for protoc_gen_validate-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 707e03a51b8f71d4658d7ee5e9001496dda7bb63b040219d2dc4f039e1076010 |
|
MD5 | f8d03a5cd5efeb00b904b8ff5e0fec2e |
|
BLAKE2b-256 | 0a16a59c0a07585258f9920a91c84d4f9f99814e4c0a90ed866f1bc5251391c6 |