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.0.tar.gz
(18.1 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 514ab33028b966a20f244766ea91dea4ceff77f507f8f230d155f0b1d428371d |
|
MD5 | 80da0dfc58ead26fbf08729319432298 |
|
BLAKE2b-256 | 38683129567a0cd9bf64696dfa147d5515e121bb77de1a28628a04e372b8ad47 |
Close
Hashes for protoc_gen_validate-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b692c2d462736ae8f1b4a96ca41928c8d2f5bb3f0019fc24b91a15ca92632a8 |
|
MD5 | 36996452808db95eed8cb96412821995 |
|
BLAKE2b-256 | 48123015d6d8891a0e683b6f24d3b3ee9a5631dfd41fb040a4343e639240bb61 |