Proto3 has been simplified such that the required
and optional
fields are no longer supported (See Why required and optional is removed in Protocol Buffers 3). Is there still a way to label a certain field as required
?
I've looked into FieldOptions
, and tried something like this:
message MyMeta {
bool isRequired = 1;
}
extend google.protobuf.FieldOptions {
MyMeta meta = 1234;
}
message Person {
string name = 1 [ (meta) = { isRequired: true }];
string address = 2 [ (meta) = { isRequired: true }];
string remarks = 3;
}
After compiling it into Java code, and as I was checking the compiled Java code I don't see any link between the fields and its metadata I specified in proto. Did I miss something here?