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 ^[A-Za-z]+( [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.1.0.tar.gz
(18.1 kB
view details)
Built Distribution
File details
Details for the file protoc_gen_validate-1.1.0.tar.gz
.
File metadata
- Download URL: protoc_gen_validate-1.1.0.tar.gz
- Upload date:
- Size: 18.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.11.1 requests/2.32.3 setuptools/70.0.0 requests-toolbelt/1.0.0 tqdm/4.66.5 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72868772348e64a5b5ee23641f411da34f1544591248601a17cdd2007eb6d492 |
|
MD5 | d68dd5e94b5883fdcade82bd979cfdaa |
|
BLAKE2b-256 | 9143a350c4f5c52da70a9e40173200da9aa575852bf7bb9e19929e5685b9c45b |
File details
Details for the file protoc_gen_validate-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: protoc_gen_validate-1.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.11.1 requests/2.32.3 setuptools/70.0.0 requests-toolbelt/1.0.0 tqdm/4.66.5 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7cd1602fa5070b52eeed53c115801664fb212f92daa1e44a5c9f10ab92a229c |
|
MD5 | ca5445dd6609d73822e454f020171625 |
|
BLAKE2b-256 | 738a503760e69a6ba2e7e63b83bf88bf677f60750c2875fa9334e8979ba15a45 |