Skip to content

Feature request: Non-nullable Message and Oneof parameter generation #242

@Dogacel

Description

@Dogacel

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions