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.3.tar.gz
(18.0 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a733b368e0415102c3298ba7720838093382ab835120e875837db2e34457f9a3 |
|
MD5 | 0723ebac813dc17025e4316ba6806405 |
|
BLAKE2b-256 | f5b60280c040abe1624befb992b84b75e21b0bfc437d88895c1e7d1b3f2aa1b1 |
Close
Hashes for protoc_gen_validate-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c982986d598a4cbfda689b72b0ec4cd07ec6875746155f9496170b1b1f1418d4 |
|
MD5 | a56a7e5739736aeff23d83f1422643de |
|
BLAKE2b-256 | 5f06bb07267915864b4239544d82aca622bd2b6baf18b5fd8d303cf451115a53 |