From README,
For proto3, the only nullable fields are other messages and oneof fields.
Note: We can update the README to include optional.
Currently there is no way to mark a message type or oneof type as required in proto3. But this is possible via plugins / options for example: protoc-gen-validate.
It could be super cool if we can generate not nullable message fields if the option exists (And possibly we can make it customizable):
Location home = 4 [(validate.rules).message.required = true];
and the generated code would have a not-nullable home type as so
val home: pbandk.Location
I think there can be stuff that we need to consider, because this will definitely break the default constructor implementation for all protos and backwards compatibility. So we might need to add additional checks and throw exceptions like validators do to overcome unexpected errors.
From README,
Currently there is no way to mark a
messagetype oroneoftype as required in proto3. But this is possible via plugins / options for example: protoc-gen-validate.It could be super cool if we can generate not nullable message fields if the option exists (And possibly we can make it customizable):
and the generated code would have a
not-nullablehome type as soI think there can be stuff that we need to consider, because this will definitely break the default constructor implementation for all protos and backwards compatibility. So we might need to add additional checks and throw exceptions like validators do to overcome unexpected errors.