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.9.1.tar.gz
(17.9 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-0.9.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca1e9bc52772c589a40121c87ab277294d01fd4984bd4f13b21cecf6f4e737ba |
|
MD5 | af1d0e59a8c8046c5b06c6249dfacd25 |
|
BLAKE2b-256 | a8957d789d8ff28565f68d7e74d1a0dda0512a5274f89806fa92fb3c2b910611 |
Close
Hashes for protoc_gen_validate-0.9.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0eb0703f420d44b0154fd2593a5cc0078d5da10156909e3c6509c6bf20d9dedc |
|
MD5 | 8aafc75854d7c35b97e7e41bba169974 |
|
BLAKE2b-256 | fef6600c521f441dab67e6c00e634e38ae0a8a9f3ec008f4014bb05c77d48a8a |