Skip to content

Commit 6fcc374

Browse files
Update README to be consistent with core Protovalidate repo (#330)
* Updates this implementation's README to incorporate changes from this weekend's update Protovalidate's README. Includes correct field number for `last_name`. * Additionally fixes one incorrectly capitalized title.
1 parent d7e6394 commit 6fcc374

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

README.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
1-
[![The Buf logo](.github/buf-logo.svg)][buf]
1+
[![The Buf logo](.github/buf-logo.svg)][buf]
22

33
# protovalidate-python
44

55
[![CI](https://github.com/bufbuild/protovalidate-python/actions/workflows/ci.yaml/badge.svg)](https://github.com/bufbuild/protovalidate-python/actions/workflows/ci.yaml)
66
[![Conformance](https://github.com/bufbuild/protovalidate-python/actions/workflows/conformance.yaml/badge.svg)](https://github.com/bufbuild/protovalidate-python/actions/workflows/conformance.yaml)
77
[![PyPI version](https://badge.fury.io/py/protovalidate.svg)](https://badge.fury.io/py/protovalidate)
88

9-
[Protovalidate][protovalidate] provides standard annotations to validate common constraints on messages and fields, as well as the ability to use [CEL][cel] to write custom constraints. It's the next generation of [protoc-gen-validate][protoc-gen-validate], the only widely used validation library for Protobuf.
9+
[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].
1010

1111
With Protovalidate, you can annotate your Protobuf messages with both standard and custom validation rules:
1212

1313
```protobuf
1414
syntax = "proto3";
1515
16-
package banking.v1;
16+
package acme.user.v1;
1717
1818
import "buf/validate/validate.proto";
1919
20-
message MoneyTransfer {
21-
string to_account_id = 1 [
22-
// Standard rule: `to_account_id` must be a UUID
23-
(buf.validate.field).string.uuid = true
24-
];
20+
message User {
21+
string id = 1 [(buf.validate.field).string.uuid = true];
22+
uint32 age = 2 [(buf.validate.field).uint32.lte = 150]; // We can only hope.
23+
string email = 3 [(buf.validate.field).string.email = true];
24+
string first_name = 4 [(buf.validate.field).string.max_len = 64];
25+
string last_name = 5 [(buf.validate.field).string.max_len = 64];
2526
26-
string from_account_id = 2 [
27-
// Standard rule: `from_account_id` must be a UUID
28-
(buf.validate.field).string.uuid = true
29-
];
30-
31-
// Custom rule: `to_account_id` and `from_account_id` can't be the same.
3227
option (buf.validate.message).cel = {
33-
id: "to_account_id.not.from_account_id"
34-
message: "to_account_id and from_account_id should not be the same value"
35-
expression: "this.to_account_id != this.from_account_id"
28+
id: "first_name_requires_last_name"
29+
message: "last_name must be present if first_name is present"
30+
expression: "!has(this.first_name) || has(this.last_name)"
3631
};
3732
}
3833
```
@@ -67,7 +62,7 @@ Highlights for Python developers include:
6762
* A comprehensive RPC quickstart for [Python and gRPC][grpc-python]
6863
* A [migration guide for protoc-gen-validate][migration-guide] users
6964

70-
## Additional Languages and Repositories
65+
## Additional languages and repositories
7166

7267
Protovalidate isn't just for Python! You might be interested in sibling repositories for other languages:
7368

@@ -81,18 +76,13 @@ Additionally, [protovalidate's core repository](https://github.com/bufbuild/prot
8176
- [Protovalidate's Protobuf API][validate-proto]
8277
- [Conformance testing utilities][conformance] for acceptance testing of `protovalidate` implementations
8378

84-
## Contribution
79+
## Contributing
8580

8681
We genuinely appreciate any help! If you'd like to contribute, check out these resources:
8782

8883
- [Contributing Guidelines][contributing]: Guidelines to make your contribution process straightforward and meaningful
8984
- [Conformance testing utilities](https://github.com/bufbuild/protovalidate/tree/main/docs/conformance.md): Utilities providing acceptance testing of `protovalidate` implementations
9085

91-
## Related Sites
92-
93-
- [Buf][buf]: Enterprise-grade Kafka and gRPC for the modern age
94-
- [Common Expression Language (CEL)][cel]: The open-source technology at the core of Protovalidate
95-
9686
## Legal
9787

9888
Offered under the [Apache 2 license][license].

0 commit comments

Comments
 (0)