[][buf]
# protovalidate-python
[](https://github.com/bufbuild/protovalidate-python/actions/workflows/ci.yaml)
[](https://github.com/bufbuild/protovalidate-python/actions/workflows/conformance.yaml)
[](https://pypi.org/project/protovalidate)
[Protovalidate][protovalidate] is the semantic validation library for Protobuf. It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL][cel] to write custom rules. It's the next generation of [protoc-gen-validate][protoc-gen-validate].
With Protovalidate, you can annotate your Protobuf messages with both standard and custom validation rules:
```protobuf
syntax = "proto3";
package acme.user.v1;
import "buf/validate/validate.proto";
message User {
string id = 1 [(buf.validate.field).string.uuid = true];
uint32 age = 2 [(buf.validate.field).uint32.lte = 150]; // We can only hope.
string email = 3 [(buf.validate.field).string.email = true];
string first_name = 4 [(buf.validate.field).string.max_len = 64];
string last_name = 5 [(buf.validate.field).string.max_len = 64];
option (buf.validate.message).cel = {
id: "first_name_requires_last_name"
message: "last_name must be present if first_name is present"
expression: "!has(this.first_name) || has(this.last_name)"
};
}
```
Once you've added `protovalidate-python` to your project, validation is idiomatic Python:
```python
try:
protovalidate.validate(message)
except protovalidate.ValidationError as e:
# Handle failure.
```
## Installation
> [!TIP]
> The easiest way to get started with Protovalidate for RPC APIs are the quickstarts in Buf's documentation. There's one available for [Python and gRPC][grpc-python].
To install the package, use `pip`:
```shell
pip install protovalidate
```
## Documentation
Comprehensive documentation for Protovalidate is available at [protovalidate.com][protovalidate].
Highlights for Python developers include:
* The [developer quickstart][quickstart]
* A comprehensive RPC quickstart for [Python and gRPC][grpc-python]
* A [migration guide for protoc-gen-validate][migration-guide] users
## Additional languages and repositories
Protovalidate isn't just for Python! You might be interested in sibling repositories for other languages:
- [`protovalidate-go`][pv-go] (Go)
- [`protovalidate-java`][pv-java] (Java)
- [`protovalidate-cc`][pv-cc] (C++)
- [`protovalidate-es`][pv-es] (TypeScript and JavaScript)
Additionally, [protovalidate's core repository](https://github.com/bufbuild/protovalidate) provides:
- [Protovalidate's Protobuf API][validate-proto]
- [Conformance testing utilities][conformance] for acceptance testing of `protovalidate` implementations
## Contributing
We genuinely appreciate any help! If you'd like to contribute, check out these resources:
- [Contributing Guidelines][contributing]: Guidelines to make your contribution process straightforward and meaningful
- [Conformance testing utilities](https://github.com/bufbuild/protovalidate/tree/main/docs/conformance.md): Utilities providing acceptance testing of `protovalidate` implementations
## Legal
Offered under the [Apache 2 license][license].
[buf]: https://buf.build
[cel]: https://cel.dev
[pv-go]: https://github.com/bufbuild/protovalidate-go
[pv-java]: https://github.com/bufbuild/protovalidate-java
[pv-python]: https://github.com/bufbuild/protovalidate-python
[pv-cc]: https://github.com/bufbuild/protovalidate-cc
[pv-es]: https://github.com/bufbuild/protovalidate-es
[buf-mod]: https://buf.build/bufbuild/protovalidate
[license]: LICENSE
[contributing]: .github/CONTRIBUTING.md
[protoc-gen-validate]: https://github.com/bufbuild/protoc-gen-validate
[protovalidate]: https://protovalidate.com
[quickstart]: https://protovalidate.com/quickstart/
[connect-go]: https://protovalidate.com/quickstart/connect-go/
[grpc-go]: https://protovalidate.com/quickstart/grpc-go/
[grpc-java]: https://protovalidate.com/quickstart/grpc-java/
[grpc-python]: https://protovalidate.com/quickstart/grpc-python/
[migration-guide]: https://protovalidate.com/migration-guides/migrate-from-protoc-gen-validate/
[conformance-executable]: ./internal/cmd/protovalidate-conformance-go/README.md
[pkg-go]: https://pkg.go.dev/github.com/bufbuild/protovalidate-go
[validate-proto]: https://buf.build/bufbuild/protovalidate/docs/main:buf.validate
[conformance]: https://github.com/bufbuild/protovalidate/blob/main/docs/conformance.md
[examples]: https://github.com/bufbuild/protovalidate/tree/main/examples
[migrate]: https://protovalidate.com/migration-guides/migrate-from-protoc-gen-validate/
Raw data
{
"_id": null,
"home_page": null,
"name": "protovalidate",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "protobuf, protocol buffer, validate",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/dd/98/1595ae90c4a29c625580ee84415bb0c752e09c6c7aa13595e8ea94a7c929/protovalidate-1.0.0.tar.gz",
"platform": null,
"description": "[][buf]\n\n# protovalidate-python\n\n[](https://github.com/bufbuild/protovalidate-python/actions/workflows/ci.yaml)\n[](https://github.com/bufbuild/protovalidate-python/actions/workflows/conformance.yaml)\n[](https://pypi.org/project/protovalidate)\n\n[Protovalidate][protovalidate] is the semantic validation library for Protobuf. It provides standard annotations to validate common rules on messages and fields, as well as the ability to use [CEL][cel] to write custom rules. It's the next generation of [protoc-gen-validate][protoc-gen-validate].\n\nWith Protovalidate, you can annotate your Protobuf messages with both standard and custom validation rules:\n\n```protobuf\nsyntax = \"proto3\";\n\npackage acme.user.v1;\n\nimport \"buf/validate/validate.proto\";\n\nmessage User {\n string id = 1 [(buf.validate.field).string.uuid = true];\n uint32 age = 2 [(buf.validate.field).uint32.lte = 150]; // We can only hope.\n string email = 3 [(buf.validate.field).string.email = true];\n string first_name = 4 [(buf.validate.field).string.max_len = 64];\n string last_name = 5 [(buf.validate.field).string.max_len = 64];\n\n option (buf.validate.message).cel = {\n id: \"first_name_requires_last_name\"\n message: \"last_name must be present if first_name is present\"\n expression: \"!has(this.first_name) || has(this.last_name)\"\n };\n}\n```\n\nOnce you've added `protovalidate-python` to your project, validation is idiomatic Python:\n\n```python\ntry:\n protovalidate.validate(message)\nexcept protovalidate.ValidationError as e:\n # Handle failure.\n```\n\n## Installation\n\n> [!TIP]\n> The easiest way to get started with Protovalidate for RPC APIs are the quickstarts in Buf's documentation. There's one available for [Python and gRPC][grpc-python].\n\nTo install the package, use `pip`:\n\n```shell\npip install protovalidate\n```\n\n## Documentation\n\nComprehensive documentation for Protovalidate is available at [protovalidate.com][protovalidate].\n\nHighlights for Python developers include:\n\n* The [developer quickstart][quickstart]\n* A comprehensive RPC quickstart for [Python and gRPC][grpc-python]\n* A [migration guide for protoc-gen-validate][migration-guide] users\n\n## Additional languages and repositories\n\nProtovalidate isn't just for Python! You might be interested in sibling repositories for other languages:\n\n- [`protovalidate-go`][pv-go] (Go)\n- [`protovalidate-java`][pv-java] (Java)\n- [`protovalidate-cc`][pv-cc] (C++)\n- [`protovalidate-es`][pv-es] (TypeScript and JavaScript)\n\nAdditionally, [protovalidate's core repository](https://github.com/bufbuild/protovalidate) provides:\n\n- [Protovalidate's Protobuf API][validate-proto]\n- [Conformance testing utilities][conformance] for acceptance testing of `protovalidate` implementations\n\n## Contributing\n\nWe genuinely appreciate any help! If you'd like to contribute, check out these resources:\n\n- [Contributing Guidelines][contributing]: Guidelines to make your contribution process straightforward and meaningful\n- [Conformance testing utilities](https://github.com/bufbuild/protovalidate/tree/main/docs/conformance.md): Utilities providing acceptance testing of `protovalidate` implementations\n\n## Legal\n\nOffered under the [Apache 2 license][license].\n\n[buf]: https://buf.build\n[cel]: https://cel.dev\n\n[pv-go]: https://github.com/bufbuild/protovalidate-go\n[pv-java]: https://github.com/bufbuild/protovalidate-java\n[pv-python]: https://github.com/bufbuild/protovalidate-python\n[pv-cc]: https://github.com/bufbuild/protovalidate-cc\n[pv-es]: https://github.com/bufbuild/protovalidate-es\n\n[buf-mod]: https://buf.build/bufbuild/protovalidate\n[license]: LICENSE\n[contributing]: .github/CONTRIBUTING.md\n\n[protoc-gen-validate]: https://github.com/bufbuild/protoc-gen-validate\n\n[protovalidate]: https://protovalidate.com\n[quickstart]: https://protovalidate.com/quickstart/\n[connect-go]: https://protovalidate.com/quickstart/connect-go/\n[grpc-go]: https://protovalidate.com/quickstart/grpc-go/\n[grpc-java]: https://protovalidate.com/quickstart/grpc-java/\n[grpc-python]: https://protovalidate.com/quickstart/grpc-python/\n[migration-guide]: https://protovalidate.com/migration-guides/migrate-from-protoc-gen-validate/\n[conformance-executable]: ./internal/cmd/protovalidate-conformance-go/README.md\n[pkg-go]: https://pkg.go.dev/github.com/bufbuild/protovalidate-go\n\n[validate-proto]: https://buf.build/bufbuild/protovalidate/docs/main:buf.validate\n[conformance]: https://github.com/bufbuild/protovalidate/blob/main/docs/conformance.md\n[examples]: https://github.com/bufbuild/protovalidate/tree/main/examples\n[migrate]: https://protovalidate.com/migration-guides/migrate-from-protoc-gen-validate/\n",
"bugtrack_url": null,
"license": null,
"summary": "Protocol Buffer Validation for Python",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/bufbuild/protovalidate-python",
"Issues": "https://github.com/bufbuild/protovalidate-python/issues",
"Source": "https://github.com/bufbuild/protovalidate-python"
},
"split_keywords": [
"protobuf",
" protocol buffer",
" validate"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "171d30a86726b317593469eb526c8ca25dd8ce7f7b9f4237137fedb1f352ffff",
"md5": "aefec02a03e8f94d35a49bc79904cac2",
"sha256": "933818942700c85d4a47f1030e61f59d7bd9a8c1572e9dc822f98eef45a39d9e"
},
"downloads": -1,
"filename": "protovalidate-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aefec02a03e8f94d35a49bc79904cac2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 29478,
"upload_time": "2025-09-12T16:28:01",
"upload_time_iso_8601": "2025-09-12T16:28:01.201925Z",
"url": "https://files.pythonhosted.org/packages/17/1d/30a86726b317593469eb526c8ca25dd8ce7f7b9f4237137fedb1f352ffff/protovalidate-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "dd981595ae90c4a29c625580ee84415bb0c752e09c6c7aa13595e8ea94a7c929",
"md5": "48e531bc3dbb75d71e1136b85b67f425",
"sha256": "926f7a212fed9190d00cc076fa24ef5e48a404b5577465028697f4dea8c4a507"
},
"downloads": -1,
"filename": "protovalidate-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "48e531bc3dbb75d71e1136b85b67f425",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 215286,
"upload_time": "2025-09-12T16:28:02",
"upload_time_iso_8601": "2025-09-12T16:28:02.665996Z",
"url": "https://files.pythonhosted.org/packages/dd/98/1595ae90c4a29c625580ee84415bb0c752e09c6c7aa13595e8ea94a7c929/protovalidate-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-12 16:28:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bufbuild",
"github_project": "protovalidate-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "protovalidate"
}