Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ADD_LICENSE_HEADER := $(BIN)/license-header \
--copyright-holder "Buf Technologies, Inc." \
--year-range "2023-2025"
# This version should be kept in sync with the version in buf.yaml
PROTOVALIDATE_VERSION ?= v0.13.0
PROTOVALIDATE_VERSION ?= v0.13.1
# Version of the cel-spec that this implementation is conformant with
# This should be kept in sync with the version in format_test.py
CEL_SPEC_VERSION ?= v0.24.0
Expand Down
4 changes: 2 additions & 2 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: v2
modules:
- path: proto
deps:
- buf.build/bufbuild/protovalidate:v0.13.0
- buf.build/bufbuild/protovalidate-testing:v0.13.0
- buf.build/bufbuild/protovalidate:v0.13.1
- buf.build/bufbuild/protovalidate-testing:v0.13.1
lint:
use:
- STANDARD
Expand Down
34 changes: 27 additions & 7 deletions gen/buf/validate/conformance/cases/messages_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions gen/buf/validate/conformance/cases/messages_pb2.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions protovalidate/internal/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,18 @@ def add_oneof(
rule: validate_pb2.MessageOneofRule,
):
fields = []
seen = set()
if len(rule.fields) == 0:
msg = f"at least one field must be specified in oneof rule for the message {self._desc.full_name}"
raise CompilationError(msg)

for name in rule.fields:
if name in self._desc.fields_by_name:
if name in seen:
msg = f"duplicate {name} in oneof rule for the message {self._desc.full_name}"
raise CompilationError(msg)
fields.append(self._desc.fields_by_name[name])
seen.add(name)
else:
msg = f'field "{name}" not found in message {self._desc.full_name}'
raise CompilationError(msg)
Expand Down
Loading