|
|
|
|
|
by madgar
3617 days ago
|
|
> Now, I have to check each field individually, in manually written code, to verify that no required fields are missing. You always had to check the individual fields for the zero value. A required field in a proto2 message can be set but also have the default value and pass initialization. |
|
No, you didn't. A required field has a value, period. If it defaults to a particular value, then that's the value it has.
If you had a non-required field, then you marked it 'optional', and checked for the field's existence (or mapped optional fields to a Maybe/Option monad representation, forcing the issue).