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.1.tar.gz
(18.1 kB
view hashes)
Built Distribution
Close
Hashes for protoc-gen-validate-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee011b07a3d6204ce55c96347617bda38d1cb2f625fc7e3282261a72601bc12f |
|
MD5 | 3fe03d9e8a49d9f971bf1590f0b28f4f |
|
BLAKE2b-256 | 23e1c99a677659da8ab96abda69d6ce778f0b1e2644b3154d9ab721c8035a83a |
Close
Hashes for protoc_gen_validate-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d57ebc2aa8a6129f93f7a7ee6fb17e6afb718e657a482ec80c7b64a9301d9c24 |
|
MD5 | feaa50e68ec34243c428be80ce036512 |
|
BLAKE2b-256 | 799835963970a0e8967abcbc8d9af39a5f216c710cb774ed133350c88f584629 |