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.0.tar.gz
(17.9 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-0.9.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae7dd1a9a8f1bfa4a31ed3f9960c2dbb8aa805ef23685219ce5f19108d806f80 |
|
MD5 | 813d54531b017f6f64c1d01bb5e67dd9 |
|
BLAKE2b-256 | e5f9e7c677b9ee66d355dfdea6670cf9d3117f76523d4fdc387ccd90aa9de57a |
Close
Hashes for protoc_gen_validate-0.9.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bff85d54be5a633105de4e5bb0f32152ac580b6dfe521b60dbe545a6f01cde9 |
|
MD5 | a8a435dc6d305f9f6a02f06aff2c77a0 |
|
BLAKE2b-256 | dec68c902dc34542b6ef3ed6764b66cad413ab6284241e66668ffc37da1fe1ed |