Skip to content
Open
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 testing/testproto/test.manual_validator.pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (p *PingRequest) Validate() error {
}

// Implements the new validation interface from protoc-gen-validate.
func (p *PingResponse) Validate(bool) error {
func (p *PingResponse) ValidateAll() error {
if p.Counter > math.MaxInt16 {
return errors.New("ping allocation exceeded")
}
Expand Down
16 changes: 8 additions & 8 deletions validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ import (
"google.golang.org/grpc/status"
)

// The validate interface starting with protoc-gen-validate v0.6.0.
// See https://github.com/envoyproxy/protoc-gen-validate/pull/455.
// The validate interface starting with protoc-gen-validate v0.6.2.
// See https://github.com/envoyproxy/protoc-gen-validate/pull/468.
type validator interface {
Validate(all bool) error
ValidateAll() error
}

// The validate interface prior to protoc-gen-validate v0.6.0.
// The validate interface prior to protoc-gen-validate v0.6.2.
type validatorLegacy interface {
Validate() error
}

func validate(req interface{}) error {
switch v := req.(type) {
case validatorLegacy:
if err := v.Validate(); err != nil {
case validator:
if err := v.ValidateAll(); err != nil {
return status.Error(codes.InvalidArgument, err.Error())
}
case validator:
if err := v.Validate(false); err != nil {
case validatorLegacy:
if err := v.Validate(); err != nil {
return status.Error(codes.InvalidArgument, err.Error())
}
}
Expand Down