[protobuf] Repeated combined with Required

2013-10-08 Thread Dror Cohen
Hi,
if I have a field that is required to show at least 1 time but can occur a 
few times - What's the expected decleration in the proto file?
I can think of the following options:
1. Just using repeated isn't good enough - it has to appear at least once.
2. Use first option and force a check in my code - seems to misuse the 
whole versionning system.
3. Using one field with required and then a field with repeated - code 
looks bad.

I'm inclined to the first option - only because in the future the field 
might become totally optional/removed (not that I can think of that 
happening but you can never know).

Your thoughts/ Suggestions?

Dror

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [protobuf] Repeated combined with Required

2013-10-08 Thread Ilia Mirkin
Protobuf is about serializing and deserializing data, not enforcing
restrictions on it. (required being the odd case there, and it is
often recommended that you avoid it.) Using repeated in the spec, and
then enforcing any additional restrictions in your code is the
preferred way to go. That way, different users will be compatible at
the wire level, but you are free to change requirements as necessary.

On Tue, Oct 8, 2013 at 1:52 AM, Dror Cohen drorco...@gmail.com wrote:
 Hi,
 if I have a field that is required to show at least 1 time but can occur a
 few times - What's the expected decleration in the proto file?
 I can think of the following options:
 1. Just using repeated isn't good enough - it has to appear at least once.
 2. Use first option and force a check in my code - seems to misuse the whole
 versionning system.
 3. Using one field with required and then a field with repeated - code looks
 bad.

 I'm inclined to the first option - only because in the future the field
 might become totally optional/removed (not that I can think of that
 happening but you can never know).

 Your thoughts/ Suggestions?

 Dror

 --
 You received this message because you are subscribed to the Google Groups
 Protocol Buffers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to protobuf+unsubscr...@googlegroups.com.
 To post to this group, send email to protobuf@googlegroups.com.
 Visit this group at http://groups.google.com/group/protobuf.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.