Skip to content

Commit e42bc75

Browse files
smaye81Chris Pine
andauthored
Update docs (#378)
This updates the docs for the oneof rule. Courtesy of @jhump --------- Co-authored-by: Chris Pine <[email protected]>
1 parent 26470e6 commit e42bc75

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

proto/protovalidate/buf/validate/validate.proto

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,18 @@ message MessageRules {
150150
// fields have explicit presence. This means that, for the purpose of determining
151151
// how many fields are set, explicitly setting such a field to its zero value is
152152
// effectively the same as not setting it at all.
153-
// 3. This will generate validation errors when unmarshalling, even from the binary
154-
// format. With a Protobuf oneof, if multiple fields are present in the serialized
155-
// form, earlier values are usually silently ignored when unmarshalling, with only
156-
// the last field being present when unmarshalling completes.
153+
// 3. This will always generate validation errors for a message unmarshalled from
154+
// serialized data that sets more than one field. With a Protobuf oneof, when
155+
// multiple fields are present in the serialized form, earlier values are usually
156+
// silently ignored when unmarshalling, with only the last field being set when
157+
// unmarshalling completes.
157158
//
158159
//
159160
// ```proto
160161
// message MyMessage {
161162
// // Only one of `field1` or `field2` _can_ be present in this message.
162163
// option (buf.validate.message).oneof = { fields: ["field1", "field2"] };
163-
// // Only one of `field3` or `field4` _must_ be present in this message.
164+
// // Exactly one of `field3` or `field4` _must_ be present in this message.
164165
// option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true };
165166
// string field1 = 1;
166167
// bytes field2 = 2;

tools/internal/gen/buf/validate/validate.pb.go

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)