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 @@ -16,7 +16,7 @@ GOLANGCI_LINT_VERSION ?= v2.1.2
# Set to use a different version of protovalidate-conformance.
# Should be kept in sync with the version referenced in buf.yaml and
# 'buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go' in go.mod.
CONFORMANCE_VERSION ?= v1.0.0-rc.1
CONFORMANCE_VERSION ?= v1.0.0-rc.2

.PHONY: help
help: ## Describe useful make targets
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:v1.0.0-rc.1
- buf.build/bufbuild/protovalidate-testing:v1.0.0-rc.1
- buf.build/bufbuild/protovalidate:v1.0.0-rc.2
- buf.build/bufbuild/protovalidate-testing:v1.0.0-rc.2
lint:
use:
- STANDARD
Expand Down
19 changes: 19 additions & 0 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ func (bldr *builder) buildMessage(
return
}

oneofRules := msgRules.GetOneof()
for _, rule := range oneofRules {
fdescs := make([]protoreflect.FieldDescriptor, 0, len(rule.GetFields()))
for _, name := range rule.GetFields() {
fdesc := desc.Fields().ByName(protoreflect.Name(name))
if fdesc == nil {
msgEval.Err = &CompilationError{cause: fmt.Errorf(
"field %q not found in message %s", name, desc.FullName())}
} else {
fdescs = append(fdescs, fdesc)
}
}
oneofEval := &oneofEvaluator{
Fields: fdescs,
Required: rule.GetRequired(),
}
msgEval.AppendNested(oneofEval)
}

steps := []func(
desc protoreflect.MessageDescriptor,
msgRules *validate.MessageRules,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module buf.build/go/protovalidate
go 1.23.0

require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-00000000000000-c7344d9f5dae.1
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-00000000000000-c6451e2c05a6.1
github.com/google/cel-go v0.25.0
github.com/stretchr/testify v1.10.0
google.golang.org/protobuf v1.36.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-00000000000000-c7344d9f5dae.1 h1:nmsl+LeZt89FPjFhJvd0LTaUjmLy4MDAC+XEbzXc3xU=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-00000000000000-c7344d9f5dae.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-00000000000000-c6451e2c05a6.1 h1:foZfk56KWDz932pQ0gr0OfM5GrEBZVJvxyBzPBkik/U=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-00000000000000-c6451e2c05a6.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U=
cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg=
cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
Expand Down
Loading