Options for oneof fields

Use this page when you have a oneof group and want to enforce that one of its cases is set.

For canonical definitions, see spine/options.proto.

Required selection: (choice) 

Use (choice).required = true on a oneof group to require selecting one of its fields.

Applies to

  • oneof groups (declared on the oneof itself, not on a field inside it).

Minimal example

import "spine/options.proto";

message Contact {
  oneof channel {
    option (choice).required = true;

    string email = 1;
    string phone = 2;
  }
}

Common combinations / gotchas 

  • Use (choice) for the group, and apply field-level constraints (like (pattern) or (required)) to individual cases when needed.
  • If the requirement is “at least one of these fields OR one of these other fields”, use message-level options with (require).fields and include oneof group names.