Skip to content

OneofValidator should allow oneof fields to be empty #378

@yuri-sergiichuk

Description

@yuri-sergiichuk

The current implementation of the OneofValidator does not allow any oneof field to be not set.

The expected behavior is that it is possible to have unset oneof fields, e.g. we have an origin_id fields in the EventContext message that may be empty by its contract:

// Meta-information for an event.
message EventContext {
    ...
    oneof origin {
        // The context of the command which generated this event.
        CommandContext command_context = 2 [(required) = true];

        // The context of the event which generated this event.
        EventContext event_context = 6 [(required) = true];

        // The event was imported using this `ActorContext`.
        ActorContext import_context = 11 [(required) = true];
    }
    ...
    // An ID of the origin messsage.
    //
    // The case of this `oneof` is always the same as the case of `origin` (except for
    // the `import_context`, which does not have a corresponding field in `origin_id`).
    //
    // The `origin` and `origin_id` groups are not merged for the reasons of binary compatibility.
    //
    oneof origin_id {

        // The ID of the origin command.
        CommandId command_id = 12;

        // The ID of the origin event.
        EventId event_id = 13;
    }
    ...
}

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions