Skip to content

Conversation

@bufdev
Copy link
Member

@bufdev bufdev commented Jun 8, 2025

Proposal is pretty self-explanatory. Oneofs are awful to use in most languages, and have other annoying problems. Similar to (buf.validate.field).required, provide a (buf.validate.message).oneof that can be specified multiple times, and will have the property that only one field can return true for has (also allowing it to be used for repeated fields). Should be pretty simple.

@github-actions
Copy link

github-actions bot commented Jun 8, 2025

The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 8, 2025, 8:52 PM

@bufdev bufdev requested review from a user, jrinehart-buf and rodaine June 8, 2025 20:44
@Alfus
Copy link
Collaborator

Alfus commented Jun 8, 2025

Huge +1, as this also solves oneofs for repeated and map fields (which cannot be used in a normal oneof)

@bufdev bufdev force-pushed the message-oneof branch 2 times, most recently from 4ff479e to 2fe38ed Compare June 8, 2025 20:52
@bufdev bufdev changed the title Proposal: (buf.validate.message).oneof = { fields: "field1", "field2" } Proposal: (buf.validate.message).oneof = { fields: ["field1", "field2"] } Jun 8, 2025
@srikrsna-buf
Copy link
Member

Added in #377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants