Mehdi Honarmand
Mehdi Honarmand

Reputation: 103

how to define repeated field as required in google protocol buffer?

how to define repeated field as required in Google protocol buffer?I have a field that modifier is repeated(repeated int32 A ).How i add required modifier to this field? in fact i want to have both modifier(required and repeated).

Upvotes: 9

Views: 4164

Answers (1)

Kenton Varda
Kenton Varda

Reputation: 45326

Sorry, there is no way to mark a repeated field as "required".

In fact, required itself is widely considered a misfeature and is being phased out in Protobuf 3.0. For an extended explanation/rant of why this is the case, see:

https://capnproto.org/faq.html#how-do-i-make-a-field-required-like-in-protocol-buffers

(That's a link to the Cap'n Proto web site, which is a competitor to Protobufs, but its author (namely, me) was also the main author of Protobuf v2.)

Upvotes: 9

Related Questions