diff --git a/Makefile b/Makefile index 34e8053c..f7589fa3 100644 --- a/Makefile +++ b/Makefile @@ -28,28 +28,23 @@ clean: ## Delete intermediate build artifacts .PHONY: test test: build ## Run unit tests - $(GO) test -vet=off -race -cover ./... + $(GO) test -race -cover ./go/... .PHONY: build build: generate ## Build all packages - $(GO) build ./... - -.PHONY: install -install: ## Install all binaries - $(GO) install ./... + $(GO) build ./go/... .PHONY: lint lint: $(BIN)/golangci-lint ## Lint Go and protobuf - $(GO) vet ./... - $(BIN)/golangci-lint run + cd ./go && ../$(BIN)/golangci-lint run .PHONY: lintfix lintfix: $(BIN)/golangci-lint ## Automatically fix some lint errors - $(BIN)/golangci-lint run --fix + cd ./go && ../$(BIN)/golangci-lint run --fix .PHONY: generate -generate: $(BIN)/buf $(BIN)/protoc-gen-go $(BIN)/license-header ## Regenerate code and licenses - rm -rf gen +generate: $(BIN)/buf $(BIN)/license-header ## Regenerate code and licenses + rm -rf go/gen PATH=$(abspath $(BIN)) buf generate @# We want to operate on a list of modified and new files, excluding @# deleted and ignored files. git-ls-files can't do this alone. comm -23 takes @@ -67,7 +62,7 @@ generate: $(BIN)/buf $(BIN)/protoc-gen-go $(BIN)/license-header ## Regenerate co .PHONY: upgrade upgrade: ## Upgrade dependencies - $(GO) get -u -t ./... && go mod tidy -v + cd ./go && $(GO) get -u -t ./... && go mod tidy -v .PHONY: checkgenerate checkgenerate: @@ -76,18 +71,18 @@ checkgenerate: .PHONY: benchmarks benchmarks: ## Run benchmarks tests - $(GO) test -bench=. -count=10 > ./.tmp/benchmarks.txt + $(GO) test -bench=. -count=10 ./go/... > ./.tmp/benchmarks.txt .PHONY: profile profile: memprofile cpuprofile ## Generate memory and cpu profile .PHONY: memprofile memprofile: - $(GO) test -bench=. -count=10 -memprofile .tmp/memprofile.out + $(GO) test -bench=. -count=10 -memprofile .tmp/memprofile.out ./go .PHONY: cpuprofile cpuprofile: - $(GO) test -bench=. -count=10 -cpuprofile .tmp/cpuprofile.out + $(GO) test -bench=. -count=10 -cpuprofile .tmp/cpuprofile.out ./go .PHONY: showmemprofile ## Visualize memory profile showmemprofile: memprofile @@ -101,11 +96,6 @@ $(BIN)/buf: Makefile @mkdir -p $(@D) GOBIN=$(abspath $(@D)) $(GO) install github.com/bufbuild/buf/cmd/buf@v1.12.0 -$(BIN)/protoc-gen-go: Makefile - @mkdir -p $(@D) - @# The version of protoc-gen-go is determined by the version in go.mod - GOBIN=$(abspath $(@D)) $(GO) install google.golang.org/protobuf/cmd/protoc-gen-go - $(BIN)/license-header: Makefile @mkdir -p $(@D) GOBIN=$(abspath $(@D)) $(GO) install \ diff --git a/benchmarks.sh b/benchmarks.sh deleted file mode 100644 index 73729500..00000000 --- a/benchmarks.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -tmpdir=$(mktemp) -rm -rf "$tmpdir" -git clone --single-branch -b main git@github.com:bufbuild/protovalidate.git "$tmpdir" 2> /dev/null -mkdir "$tmpdir"/.tmp - -go test -bench=. -count=10 > "$tmpdir"/.tmp/benchmark_new_branch.txt - -cd "$tmpdir" -go test -bench=. -count=10 > .tmp/benchmark_main.txt -benchstat .tmp/benchmark_main.txt .tmp/benchmark_new_branch.txt - -rm -rf "$tmpdir" diff --git a/buf.gen.yaml b/buf.gen.yaml index 480079de..07e309f7 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -3,8 +3,8 @@ version: v1 managed: enabled: true go_package_prefix: - default: github.com/bufbuild/protovalidate/gen + default: github.com/bufbuild/protovalidate/go/gen plugins: - plugin: buf.build/protocolbuffers/go - out: gen + out: go/gen opt: paths=source_relative diff --git a/go.mod b/go.mod deleted file mode 100644 index e49f9122..00000000 --- a/go.mod +++ /dev/null @@ -1,22 +0,0 @@ -module github.com/bufbuild/protovalidate - -go 1.19 - -require ( - github.com/google/cel-go v0.14.0 - github.com/stretchr/testify v1.8.1 - golang.org/x/sync v0.1.0 - google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 -) - -require ( - github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/go-cmp v0.5.9 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stoewer/go-strcase v1.2.0 // indirect - golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect - golang.org/x/text v0.6.0 // indirect - google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/go.work b/go.work new file mode 100644 index 00000000..228ecaf7 --- /dev/null +++ b/go.work @@ -0,0 +1,3 @@ +use ( + "go" +) \ No newline at end of file diff --git a/go/errors.go b/go/errors.go new file mode 100644 index 00000000..715e80ff --- /dev/null +++ b/go/errors.go @@ -0,0 +1,108 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protovalidate + +import ( + "fmt" + "strings" + + "github.com/bufbuild/protovalidate/go/gen/buf/validate" +) + +func mergeErrors(dst, src error, failFast bool) (err error, ok bool) { + if src == nil { + return dst, true + } + + srcValErrs, ok := src.(*ValidationError) + if !ok { + return src, false + } + + if dst == nil { + return src, !(failFast && srcValErrs.hasViolations()) + } + + dstValErrs, ok := dst.(*ValidationError) + if !ok { + // what should we do here? + return dst, false + } + + dstValErrs.Violations = append(dstValErrs.Violations, srcValErrs.Violations...) + return dst, !(failFast && dstValErrs.hasViolations()) +} + +// A ValidationError is returned if one or more constraint violations were +// detected. +type ValidationError validate.Violations + +func (err *ValidationError) Error() string { + sb := &strings.Builder{} + sb.WriteString("[protovalidate] validation error:\n") + for _, violation := range err.Violations { + sb.WriteString(" - ") + if violation.FieldPath != "" { + sb.WriteString(violation.FieldPath) + sb.WriteString(": ") + } + _, _ = fmt.Fprintf(sb, "%s [%s]\n", + violation.Message, + violation.ConstraintId) + } + return sb.String() +} + +func (err *ValidationError) ToProto() *validate.Violations { return (*validate.Violations)(err) } + +func (err *ValidationError) prefixPaths(prefix string, sep string) { + for _, violation := range err.Violations { + if violation.FieldPath == "" { + violation.FieldPath = prefix + } else { + violation.FieldPath = prefix + sep + violation.FieldPath + } + } +} + +func (err *ValidationError) hasViolations() bool { + return err != nil && len(err.Violations) > 0 +} + +// A RuntimeError is returned if a valid CEL expression evaluation is terminated. +// The two built-in reasons are 'no_matching_overload' when a CEL function has +// no overload for the types of the arguments or 'no_such_field' when a map or +// message does not contain the desired field. +type RuntimeError struct { + cause error +} + +func (err RuntimeError) Error() string { + return fmt.Sprintf("[protovalidate] runtime error: %v", err.cause) +} + +func (err RuntimeError) Unwrap() error { return err.cause } + +// A CompilationError is returned if a CEL expression cannot be compiled and +// type-checked. +type CompilationError struct { + cause error +} + +func (err CompilationError) Error() string { + return fmt.Sprintf("[protovalidate] compilation error: %v", err.cause) +} + +func (err CompilationError) Unwrap() error { return err.cause } diff --git a/go/evaluator.go b/go/evaluator.go new file mode 100644 index 00000000..10268b43 --- /dev/null +++ b/go/evaluator.go @@ -0,0 +1,125 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protovalidate + +import ( + validatev2 "github.com/bufbuild/protovalidate/go/gen/buf/validate" + "google.golang.org/protobuf/reflect/protoreflect" +) + +type evaluator interface { + evaluate(msg protoreflect.Message, failFast bool) error +} + +type messageEvaluator struct { + err error + constraints []evaluator +} + +func (m *messageEvaluator) evaluate(msg protoreflect.Message, failFast bool) error { + if err := m.err; err != nil { + return err + } + var ( + err error + ok bool + ) + for _, constraint := range m.constraints { + evalErr := constraint.evaluate(msg, failFast) + if err, ok = mergeErrors(err, evalErr, failFast); !ok { + break + } + } + return err +} + +type messageExpressionEvaluator struct { + exprs []compiledExpression +} + +func (m messageExpressionEvaluator) evaluate(msg protoreflect.Message, failFast bool) error { + binding := namedBinding{name: "this", val: msg.Interface()} + return evalExprs(m.exprs, binding, failFast) +} + +type fieldExpressionEvaluator struct { + field protoreflect.FieldDescriptor + exprs []compiledExpression +} + +func (f fieldExpressionEvaluator) evaluate(msg protoreflect.Message, failFast bool) error { + binding := namedBinding{name: "this", val: msg.Get(f.field)} + err := evalExprs(f.exprs, binding, failFast) + if valErr, ok := err.(*ValidationError); ok { + valErr.prefixPaths(string(f.field.Name()), ".") + } + return err +} + +type messageFieldEvaluator struct { + field protoreflect.FieldDescriptor + embeddedMessageEvaluator +} + +func (m messageFieldEvaluator) evaluate(msg protoreflect.Message, failFast bool) error { + fldMsg := msg.Get(m.field).Message() + err := m.embeddedMessageEvaluator.evaluate(fldMsg, failFast) + if valErr, ok := err.(*ValidationError); ok { + valErr.prefixPaths(string(m.field.FullName()), ".") + } + return err +} + +type embeddedMessageEvaluator struct { + required bool + skipped bool + + msgEval *messageEvaluator + exprs []compiledExpression +} + +func (e embeddedMessageEvaluator) evaluate(msg protoreflect.Message, failFast bool) error { + if e.required && !msg.IsValid() { + return &ValidationError{Violations: []*validatev2.Violation{{ + ConstraintId: "required", + Message: "value is required", + }}} + } + + var ( + err error + ok bool + ) + if !e.skipped && msg.IsValid() { + evalErr := e.msgEval.evaluate(msg, failFast) + err, ok = mergeErrors(err, evalErr, failFast) + if !ok { + return err + } + } + + binding := namedBinding{name: "this", val: msg.Interface()} + evalErr := evalExprs(e.exprs, binding, failFast) + err, _ = mergeErrors(err, evalErr, failFast) + return err +} + +var ( + _ evaluator = (*messageEvaluator)(nil) + _ evaluator = messageExpressionEvaluator{} + _ evaluator = fieldExpressionEvaluator{} + _ evaluator = messageFieldEvaluator{} + _ evaluator = embeddedMessageEvaluator{} +) diff --git a/go/expressions.go b/go/expressions.go new file mode 100644 index 00000000..02d5f7b6 --- /dev/null +++ b/go/expressions.go @@ -0,0 +1,92 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protovalidate + +import ( + "fmt" + + validatev2 "github.com/bufbuild/protovalidate/go/gen/buf/validate" + "github.com/google/cel-go/cel" + "github.com/google/cel-go/interpreter" +) + +type Expression interface { + GetId() string + GetMessage() string + GetExpression() string +} + +func evalExprs(exprs []compiledExpression, binding interpreter.Activation, failFast bool) error { + var ( + err error + ok bool + ) + for _, expr := range exprs { + evalErr := expr.eval(binding) + if err, ok = mergeErrors(err, evalErr, failFast); !ok { + break + } + } + return err +} + +type compiledExpression struct { + program cel.Program + source Expression +} + +func (expr compiledExpression) eval(bindings interpreter.Activation) error { + value, _, err := expr.program.Eval(bindings) + if err != nil { + return RuntimeError{ + cause: fmt.Errorf("error evaluating %s: %w", expr.source.GetId(), err), + } + } + switch val := value.Value().(type) { + case string: + if val == "" { + return nil + } + return &ValidationError{Violations: []*validatev2.Violation{{ + ConstraintId: expr.source.GetId(), + Message: val, + }}} + case bool: + if val { + return nil + } + return &ValidationError{Violations: []*validatev2.Violation{{ + ConstraintId: expr.source.GetId(), + Message: expr.source.GetMessage(), + }}} + default: + return RuntimeError{ + cause: fmt.Errorf("resolved to an unexpected type %T", val), + } + } +} + +type namedBinding struct { + name string + val any +} + +func (binding namedBinding) ResolveName(name string) (any, bool) { + return binding.val, name == binding.name +} + +func (binding namedBinding) Parent() interpreter.Activation { return nil } + +var _ interpreter.Activation = namedBinding{} diff --git a/gen/buf/validate/expression.pb.go b/go/gen/buf/validate/expression.pb.go similarity index 50% rename from gen/buf/validate/expression.pb.go rename to go/gen/buf/validate/expression.pb.go index 179d6b14..a081ff4d 100644 --- a/gen/buf/validate/expression.pb.go +++ b/go/gen/buf/validate/expression.pb.go @@ -107,6 +107,116 @@ func (x *Constraint) GetExpression() string { return "" } +type Violations struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Violations []*Violation `protobuf:"bytes,1,rep,name=violations,proto3" json:"violations,omitempty"` +} + +func (x *Violations) Reset() { + *x = Violations{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_expression_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Violations) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Violations) ProtoMessage() {} + +func (x *Violations) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_expression_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Violations.ProtoReflect.Descriptor instead. +func (*Violations) Descriptor() ([]byte, []int) { + return file_buf_validate_expression_proto_rawDescGZIP(), []int{1} +} + +func (x *Violations) GetViolations() []*Violation { + if x != nil { + return x.Violations + } + return nil +} + +type Violation struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FieldPath string `protobuf:"bytes,1,opt,name=field_path,json=fieldPath,proto3" json:"field_path,omitempty"` + ConstraintId string `protobuf:"bytes,2,opt,name=constraint_id,json=constraintId,proto3" json:"constraint_id,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *Violation) Reset() { + *x = Violation{} + if protoimpl.UnsafeEnabled { + mi := &file_buf_validate_expression_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Violation) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Violation) ProtoMessage() {} + +func (x *Violation) ProtoReflect() protoreflect.Message { + mi := &file_buf_validate_expression_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Violation.ProtoReflect.Descriptor instead. +func (*Violation) Descriptor() ([]byte, []int) { + return file_buf_validate_expression_proto_rawDescGZIP(), []int{2} +} + +func (x *Violation) GetFieldPath() string { + if x != nil { + return x.FieldPath + } + return "" +} + +func (x *Violation) GetConstraintId() string { + if x != nil { + return x.ConstraintId + } + return "" +} + +func (x *Violation) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + var File_buf_validate_expression_proto protoreflect.FileDescriptor var file_buf_validate_expression_proto_rawDesc = []byte{ @@ -118,18 +228,29 @@ var file_buf_validate_expression_proto_rawDesc = []byte{ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x72, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0xa8, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, - 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, 0x0f, 0x45, 0x78, 0x70, 0x72, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, - 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0xa2, 0x02, 0x03, 0x42, 0x56, 0x58, 0xaa, 0x02, 0x0c, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xca, 0x02, 0x0c, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0xe2, 0x02, 0x18, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x0d, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x45, 0x0a, 0x0a, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x37, 0x0a, 0x0a, 0x76, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x0a, 0x76, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x69, 0x0a, 0x09, + 0x56, 0x69, 0x6f, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x6e, 0x73, + 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42, 0xab, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, + 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, 0x0f, 0x45, 0x78, + 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, + 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, + 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x03, 0x42, 0x56, 0x58, 0xaa, 0x02, 0x0c, 0x42, + 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xca, 0x02, 0x0c, 0x42, 0x75, + 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xe2, 0x02, 0x18, 0x42, 0x75, 0x66, + 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -144,16 +265,19 @@ func file_buf_validate_expression_proto_rawDescGZIP() []byte { return file_buf_validate_expression_proto_rawDescData } -var file_buf_validate_expression_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_buf_validate_expression_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_buf_validate_expression_proto_goTypes = []interface{}{ (*Constraint)(nil), // 0: buf.validate.Constraint + (*Violations)(nil), // 1: buf.validate.Violations + (*Violation)(nil), // 2: buf.validate.Violation } var file_buf_validate_expression_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 2, // 0: buf.validate.Violations.violations:type_name -> buf.validate.Violation + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_buf_validate_expression_proto_init() } @@ -174,6 +298,30 @@ func file_buf_validate_expression_proto_init() { return nil } } + file_buf_validate_expression_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Violations); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_buf_validate_expression_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Violation); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -181,7 +329,7 @@ func file_buf_validate_expression_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_buf_validate_expression_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/gen/buf/validate/private/private.pb.go b/go/gen/buf/validate/private/private.pb.go similarity index 93% rename from gen/buf/validate/private/private.pb.go rename to go/gen/buf/validate/private/private.pb.go index 3db34c98..1512c834 100644 --- a/gen/buf/validate/private/private.pb.go +++ b/go/gen/buf/validate/private/private.pb.go @@ -266,21 +266,21 @@ var file_buf_validate_private_private_proto_rawDesc = []byte{ 0x32, 0x26, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x88, - 0x01, 0x01, 0x42, 0xd8, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, + 0x01, 0x01, 0x42, 0xdb, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x42, 0x0c, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, + 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x03, 0x42, 0x56, - 0x50, 0xaa, 0x02, 0x14, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0xca, 0x02, 0x15, 0x42, 0x75, 0x66, 0x5c, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, - 0xe2, 0x02, 0x21, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, - 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0xa2, 0x02, + 0x03, 0x42, 0x56, 0x50, 0xaa, 0x02, 0x14, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x2e, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0xca, 0x02, 0x15, 0x42, 0x75, + 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x50, 0x72, 0x69, 0x76, 0x61, + 0x74, 0x65, 0x5f, 0xe2, 0x02, 0x21, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x65, 0x5c, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x5f, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, 0x42, 0x75, 0x66, 0x3a, 0x3a, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x3a, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/buf/validate/validate.pb.go b/go/gen/buf/validate/validate.pb.go similarity index 99% rename from gen/buf/validate/validate.pb.go rename to go/gen/buf/validate/validate.pb.go index a72476ce..b4183e57 100644 --- a/gen/buf/validate/validate.pb.go +++ b/go/gen/buf/validate/validate.pb.go @@ -21,7 +21,7 @@ package validate import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate/private" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate/private" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" descriptorpb "google.golang.org/protobuf/types/descriptorpb" @@ -4867,17 +4867,18 @@ var file_buf_validate_validate_proto_rawDesc = []byte{ 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x72, 0x61, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x88, 0x01, 0x01, 0x42, - 0xa6, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, + 0xa9, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x62, 0x75, 0x66, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x42, 0x0d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x62, 0x75, 0x66, - 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x03, 0x42, 0x56, 0x58, 0xaa, - 0x02, 0x0c, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xca, 0x02, - 0x0c, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xe2, 0x02, 0x18, - 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, 0x47, 0x50, 0x42, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, 0x75, 0x66, 0x3a, 0x3a, - 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, + 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0xa2, 0x02, 0x03, 0x42, + 0x56, 0x58, 0xaa, 0x02, 0x0c, 0x42, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0xca, 0x02, 0x0c, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0xe2, 0x02, 0x18, 0x42, 0x75, 0x66, 0x5c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0d, 0x42, 0x75, + 0x66, 0x3a, 0x3a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/gen/example/v1/example.pb.go b/go/gen/example/v1/example.pb.go similarity index 92% rename from gen/example/v1/example.pb.go rename to go/gen/example/v1/example.pb.go index f6546961..f0ce572a 100644 --- a/gen/example/v1/example.pb.go +++ b/go/gen/example/v1/example.pb.go @@ -21,7 +21,7 @@ package examplev1 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -186,18 +186,18 @@ var file_example_v1_example_proto_rawDesc = []byte{ 0x56, 0xc0, 0x52, 0x03, 0x6c, 0x61, 0x74, 0x12, 0x2a, 0x0a, 0x03, 0x6c, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x42, 0x18, 0xfa, 0xf7, 0x18, 0x14, 0x12, 0x12, 0x19, 0x33, 0x33, 0x33, 0x33, 0x33, 0x83, 0x66, 0x40, 0x29, 0x33, 0x33, 0x33, 0x33, 0x33, 0x83, 0x66, 0xc0, 0x52, 0x03, - 0x6c, 0x6e, 0x67, 0x42, 0xa3, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x78, 0x61, 0x6d, + 0x6c, 0x6e, 0x67, 0x42, 0xa6, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, - 0x76, 0x31, 0xa2, 0x02, 0x03, 0x45, 0x58, 0x58, 0xaa, 0x02, 0x0a, 0x45, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0a, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5c, - 0x56, 0x31, 0xe2, 0x02, 0x16, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b, 0x45, 0x78, - 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, + 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x78, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x45, 0x58, 0x58, 0xaa, 0x02, 0x0a, 0x45, 0x78, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0a, 0x45, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x16, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5c, + 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, + 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/go/gen/example/v1/validations.pb.go b/go/gen/example/v1/validations.pb.go new file mode 100644 index 00000000..5a017c0d --- /dev/null +++ b/go/gen/example/v1/validations.pb.go @@ -0,0 +1,401 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.30.0 +// protoc (unknown) +// source: example/v1/validations.proto + +package examplev1 + +import ( + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type HasMsgExprs struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` + Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` +} + +func (x *HasMsgExprs) Reset() { + *x = HasMsgExprs{} + if protoimpl.UnsafeEnabled { + mi := &file_example_v1_validations_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HasMsgExprs) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HasMsgExprs) ProtoMessage() {} + +func (x *HasMsgExprs) ProtoReflect() protoreflect.Message { + mi := &file_example_v1_validations_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HasMsgExprs.ProtoReflect.Descriptor instead. +func (*HasMsgExprs) Descriptor() ([]byte, []int) { + return file_example_v1_validations_proto_rawDescGZIP(), []int{0} +} + +func (x *HasMsgExprs) GetX() int32 { + if x != nil { + return x.X + } + return 0 +} + +func (x *HasMsgExprs) GetY() int32 { + if x != nil { + return x.Y + } + return 0 +} + +type SelfRecursive struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` + Turtle *SelfRecursive `protobuf:"bytes,2,opt,name=turtle,proto3" json:"turtle,omitempty"` +} + +func (x *SelfRecursive) Reset() { + *x = SelfRecursive{} + if protoimpl.UnsafeEnabled { + mi := &file_example_v1_validations_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SelfRecursive) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SelfRecursive) ProtoMessage() {} + +func (x *SelfRecursive) ProtoReflect() protoreflect.Message { + mi := &file_example_v1_validations_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SelfRecursive.ProtoReflect.Descriptor instead. +func (*SelfRecursive) Descriptor() ([]byte, []int) { + return file_example_v1_validations_proto_rawDescGZIP(), []int{1} +} + +func (x *SelfRecursive) GetX() int32 { + if x != nil { + return x.X + } + return 0 +} + +func (x *SelfRecursive) GetTurtle() *SelfRecursive { + if x != nil { + return x.Turtle + } + return nil +} + +type LoopRecursiveA struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + B *LoopRecursiveB `protobuf:"bytes,1,opt,name=b,proto3" json:"b,omitempty"` +} + +func (x *LoopRecursiveA) Reset() { + *x = LoopRecursiveA{} + if protoimpl.UnsafeEnabled { + mi := &file_example_v1_validations_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoopRecursiveA) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoopRecursiveA) ProtoMessage() {} + +func (x *LoopRecursiveA) ProtoReflect() protoreflect.Message { + mi := &file_example_v1_validations_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoopRecursiveA.ProtoReflect.Descriptor instead. +func (*LoopRecursiveA) Descriptor() ([]byte, []int) { + return file_example_v1_validations_proto_rawDescGZIP(), []int{2} +} + +func (x *LoopRecursiveA) GetB() *LoopRecursiveB { + if x != nil { + return x.B + } + return nil +} + +type LoopRecursiveB struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + A *LoopRecursiveA `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` +} + +func (x *LoopRecursiveB) Reset() { + *x = LoopRecursiveB{} + if protoimpl.UnsafeEnabled { + mi := &file_example_v1_validations_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *LoopRecursiveB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoopRecursiveB) ProtoMessage() {} + +func (x *LoopRecursiveB) ProtoReflect() protoreflect.Message { + mi := &file_example_v1_validations_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoopRecursiveB.ProtoReflect.Descriptor instead. +func (*LoopRecursiveB) Descriptor() ([]byte, []int) { + return file_example_v1_validations_proto_rawDescGZIP(), []int{3} +} + +func (x *LoopRecursiveB) GetA() *LoopRecursiveA { + if x != nil { + return x.A + } + return nil +} + +var File_example_v1_validations_proto protoreflect.FileDescriptor + +var file_example_v1_validations_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x90, 0x02, 0x0a, 0x0b, 0x48, 0x61, 0x73, 0x4d, + 0x73, 0x67, 0x45, 0x78, 0x70, 0x72, 0x73, 0x12, 0x80, 0x01, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x42, 0x72, 0xfa, 0xf7, 0x18, 0x6e, 0xba, 0x01, 0x27, 0x0a, 0x06, 0x78, 0x5f, + 0x65, 0x76, 0x65, 0x6e, 0x12, 0x0e, 0x78, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, + 0x65, 0x76, 0x65, 0x6e, 0x1a, 0x0d, 0x74, 0x68, 0x69, 0x73, 0x20, 0x25, 0x20, 0x32, 0x20, 0x3d, + 0x3d, 0x20, 0x30, 0xba, 0x01, 0x41, 0x0a, 0x0b, 0x78, 0x5f, 0x63, 0x6f, 0x70, 0x72, 0x69, 0x6d, + 0x65, 0x5f, 0x33, 0x1a, 0x32, 0x74, 0x68, 0x69, 0x73, 0x20, 0x25, 0x20, 0x33, 0x20, 0x21, 0x3d, + 0x20, 0x30, 0x20, 0x3f, 0x20, 0x27, 0x27, 0x3a, 0x20, 0x27, 0x78, 0x20, 0x6d, 0x75, 0x73, 0x74, + 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x62, 0x65, 0x20, 0x64, 0x69, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, + 0x65, 0x20, 0x62, 0x79, 0x20, 0x33, 0x27, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x3a, 0x70, 0xfa, 0xf7, 0x18, 0x6c, 0x1a, 0x30, + 0x0a, 0x06, 0x78, 0x5f, 0x6c, 0x74, 0x5f, 0x79, 0x12, 0x15, 0x78, 0x20, 0x6d, 0x75, 0x73, 0x74, + 0x20, 0x62, 0x65, 0x20, 0x6c, 0x65, 0x73, 0x73, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x20, 0x79, 0x1a, + 0x0f, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x78, 0x20, 0x3c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x79, + 0x1a, 0x38, 0x0a, 0x07, 0x79, 0x5f, 0x67, 0x74, 0x5f, 0x34, 0x32, 0x1a, 0x2d, 0x74, 0x68, 0x69, + 0x73, 0x2e, 0x79, 0x20, 0x3e, 0x20, 0x34, 0x32, 0x20, 0x3f, 0x20, 0x27, 0x27, 0x3a, 0x20, 0x27, + 0x79, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, 0x67, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x72, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x20, 0x34, 0x32, 0x27, 0x22, 0xa2, 0x01, 0x0a, 0x0d, 0x53, + 0x65, 0x6c, 0x66, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x12, 0x0c, 0x0a, 0x01, + 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x31, 0x0a, 0x06, 0x74, 0x75, + 0x72, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x65, 0x78, 0x61, + 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x6c, 0x66, 0x52, 0x65, 0x63, 0x75, + 0x72, 0x73, 0x69, 0x76, 0x65, 0x52, 0x06, 0x74, 0x75, 0x72, 0x74, 0x6c, 0x65, 0x3a, 0x50, 0xfa, + 0xf7, 0x18, 0x4c, 0x1a, 0x4a, 0x0a, 0x0e, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x74, 0x75, + 0x72, 0x74, 0x6c, 0x65, 0x73, 0x12, 0x1f, 0x61, 0x64, 0x6a, 0x61, 0x63, 0x65, 0x6e, 0x74, 0x20, + 0x74, 0x75, 0x72, 0x74, 0x6c, 0x65, 0x73, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, 0x65, 0x20, + 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x1a, 0x17, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x78, 0x20, 0x21, + 0x3d, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x74, 0x75, 0x72, 0x74, 0x6c, 0x65, 0x2e, 0x78, 0x22, + 0x3a, 0x0a, 0x0e, 0x4c, 0x6f, 0x6f, 0x70, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, + 0x41, 0x12, 0x28, 0x0a, 0x01, 0x62, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x70, 0x52, 0x65, + 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x42, 0x52, 0x01, 0x62, 0x22, 0x3a, 0x0a, 0x0e, 0x4c, + 0x6f, 0x6f, 0x70, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, 0x69, 0x76, 0x65, 0x42, 0x12, 0x28, 0x0a, + 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x6f, 0x70, 0x52, 0x65, 0x63, 0x75, 0x72, 0x73, + 0x69, 0x76, 0x65, 0x41, 0x52, 0x01, 0x61, 0x42, 0xaa, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, + 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3d, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, + 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, + 0x45, 0x58, 0x58, 0xaa, 0x02, 0x0a, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x56, 0x31, + 0xca, 0x02, 0x0a, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x16, + 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, + 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_example_v1_validations_proto_rawDescOnce sync.Once + file_example_v1_validations_proto_rawDescData = file_example_v1_validations_proto_rawDesc +) + +func file_example_v1_validations_proto_rawDescGZIP() []byte { + file_example_v1_validations_proto_rawDescOnce.Do(func() { + file_example_v1_validations_proto_rawDescData = protoimpl.X.CompressGZIP(file_example_v1_validations_proto_rawDescData) + }) + return file_example_v1_validations_proto_rawDescData +} + +var file_example_v1_validations_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_example_v1_validations_proto_goTypes = []interface{}{ + (*HasMsgExprs)(nil), // 0: example.v1.HasMsgExprs + (*SelfRecursive)(nil), // 1: example.v1.SelfRecursive + (*LoopRecursiveA)(nil), // 2: example.v1.LoopRecursiveA + (*LoopRecursiveB)(nil), // 3: example.v1.LoopRecursiveB +} +var file_example_v1_validations_proto_depIdxs = []int32{ + 1, // 0: example.v1.SelfRecursive.turtle:type_name -> example.v1.SelfRecursive + 3, // 1: example.v1.LoopRecursiveA.b:type_name -> example.v1.LoopRecursiveB + 2, // 2: example.v1.LoopRecursiveB.a:type_name -> example.v1.LoopRecursiveA + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_example_v1_validations_proto_init() } +func file_example_v1_validations_proto_init() { + if File_example_v1_validations_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_example_v1_validations_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HasMsgExprs); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_v1_validations_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SelfRecursive); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_v1_validations_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoopRecursiveA); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_example_v1_validations_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*LoopRecursiveB); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_example_v1_validations_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_example_v1_validations_proto_goTypes, + DependencyIndexes: file_example_v1_validations_proto_depIdxs, + MessageInfos: file_example_v1_validations_proto_msgTypes, + }.Build() + File_example_v1_validations_proto = out.File + file_example_v1_validations_proto_rawDesc = nil + file_example_v1_validations_proto_goTypes = nil + file_example_v1_validations_proto_depIdxs = nil +} diff --git a/gen/tests/harness/cases/other_package/v2/embed.pb.go b/go/gen/tests/harness/cases/other_package/v2/embed.pb.go similarity index 88% rename from gen/tests/harness/cases/other_package/v2/embed.pb.go rename to go/gen/tests/harness/cases/other_package/v2/embed.pb.go index 302f1c9d..5cbe1893 100644 --- a/gen/tests/harness/cases/other_package/v2/embed.pb.go +++ b/go/gen/tests/harness/cases/other_package/v2/embed.pb.go @@ -21,7 +21,7 @@ package other_packagev2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -235,28 +235,28 @@ var file_tests_harness_cases_other_package_v2_embed_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x45, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x55, 0x4d, 0x45, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x55, 0x4d, - 0x45, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x01, 0x42, 0xc3, + 0x45, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x01, 0x42, 0xc6, 0x02, 0x0a, 0x28, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x45, 0x6d, 0x62, - 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x5a, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x5d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, - 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, - 0x61, 0x73, 0x65, 0x73, 0x2f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, - 0x67, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x63, 0x6b, - 0x61, 0x67, 0x65, 0x76, 0x32, 0xa2, 0x02, 0x04, 0x54, 0x48, 0x43, 0x4f, 0xaa, 0x02, 0x23, 0x54, - 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, - 0x65, 0x73, 0x2e, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, - 0x56, 0x32, 0xca, 0x02, 0x23, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, - 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x2f, 0x54, 0x65, 0x73, 0x74, 0x73, - 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x4f, - 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x27, 0x54, 0x65, 0x73, - 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, - 0x65, 0x73, 0x3a, 0x3a, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, + 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x76, 0x32, 0xa2, 0x02, 0x04, 0x54, 0x48, 0x43, 0x4f, 0xaa, + 0x02, 0x23, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x23, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x4f, 0x74, 0x68, 0x65, + 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x2f, 0x54, 0x65, + 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, + 0x73, 0x5c, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, + 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x27, + 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/subdirectory/v2/in_subdirectory.pb.go b/go/gen/tests/harness/cases/subdirectory/v2/in_subdirectory.pb.go similarity index 72% rename from gen/tests/harness/cases/subdirectory/v2/in_subdirectory.pb.go rename to go/gen/tests/harness/cases/subdirectory/v2/in_subdirectory.pb.go index 544b7958..bc71d7b4 100644 --- a/gen/tests/harness/cases/subdirectory/v2/in_subdirectory.pb.go +++ b/go/gen/tests/harness/cases/subdirectory/v2/in_subdirectory.pb.go @@ -21,7 +21,7 @@ package subdirectoryv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -44,29 +44,29 @@ var file_tests_harness_cases_subdirectory_v2_in_subdirectory_proto_rawDesc = []b 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x32, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0xc9, 0x02, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0xcc, 0x02, 0x0a, 0x27, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x76, 0x32, 0x42, 0x13, 0x49, 0x6e, 0x53, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x58, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, + 0x5a, 0x5b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, - 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x73, 0x75, 0x62, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x32, 0x3b, 0x73, 0x75, 0x62, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x76, 0x32, 0xa2, 0x02, 0x04, 0x54, 0x48, 0x43, - 0x53, 0xaa, 0x02, 0x23, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x23, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, - 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x53, 0x75, - 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x2f, - 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, - 0x73, 0x65, 0x73, 0x5c, 0x53, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, - 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x27, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x6f, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, + 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x73, + 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x76, 0x32, 0x3b, 0x73, + 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x76, 0x32, 0xa2, 0x02, 0x04, + 0x54, 0x48, 0x43, 0x53, 0xaa, 0x02, 0x23, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x53, 0x75, 0x62, 0x64, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x23, 0x54, 0x65, 0x73, + 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, + 0x5c, 0x53, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x5c, 0x56, 0x32, + 0xe2, 0x02, 0x2f, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, + 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x53, 0x75, 0x62, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x79, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x27, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x75, 0x62, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var file_tests_harness_cases_subdirectory_v2_in_subdirectory_proto_goTypes = []interface{}{} diff --git a/gen/tests/harness/cases/v2/bool.pb.go b/go/gen/tests/harness/cases/v2/bool.pb.go similarity index 89% rename from gen/tests/harness/cases/v2/bool.pb.go rename to go/gen/tests/harness/cases/v2/bool.pb.go index e398c607..ff88968c 100644 --- a/gen/tests/harness/cases/v2/bool.pb.go +++ b/go/gen/tests/harness/cases/v2/bool.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -192,22 +192,22 @@ var file_tests_harness_cases_v2_bool_proto_rawDesc = []byte{ 0x76, 0x61, 0x6c, 0x22, 0x2c, 0x0a, 0x0e, 0x42, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x46, 0x61, 0x6c, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x42, 0x08, 0xfa, 0xf7, 0x18, 0x04, 0x6a, 0x02, 0x08, 0x00, 0x52, 0x03, 0x76, 0x61, - 0x6c, 0x42, 0xe8, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, + 0x6c, 0x42, 0xeb, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, - 0x42, 0x09, 0x42, 0x6f, 0x6f, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, + 0x42, 0x09, 0x42, 0x6f, 0x6f, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, - 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, - 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, - 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, - 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, - 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, + 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, + 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, + 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, + 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/bytes.pb.go b/go/gen/tests/harness/cases/v2/bytes.pb.go similarity index 96% rename from gen/tests/harness/cases/v2/bytes.pb.go rename to go/gen/tests/harness/cases/v2/bytes.pb.go index 47b2a620..47eda04e 100644 --- a/gen/tests/harness/cases/v2/bytes.pb.go +++ b/go/gen/tests/harness/cases/v2/bytes.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -890,22 +890,22 @@ var file_tests_harness_cases_v2_bytes_proto_rawDesc = []byte{ 0x76, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x0f, 0x42, 0x79, 0x74, 0x65, 0x73, 0x49, 0x50, 0x76, 0x36, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0a, 0xfa, 0xf7, 0x18, 0x06, 0x7a, 0x04, 0x70, 0x01, 0x60, 0x01, 0x52, - 0x03, 0x76, 0x61, 0x6c, 0x42, 0xe9, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, + 0x03, 0x76, 0x61, 0x6c, 0x42, 0xec, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x42, 0x79, 0x74, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, + 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, - 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, - 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, - 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, - 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, - 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, - 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, - 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, - 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, + 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, + 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, + 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, + 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, + 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, + 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, + 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, + 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, + 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/enums.pb.go b/go/gen/tests/harness/cases/v2/enums.pb.go similarity index 97% rename from gen/tests/harness/cases/v2/enums.pb.go rename to go/gen/tests/harness/cases/v2/enums.pb.go index 312aa736..2df97eed 100644 --- a/gen/tests/harness/cases/v2/enums.pb.go +++ b/go/gen/tests/harness/cases/v2/enums.pb.go @@ -21,9 +21,9 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" - v2 "github.com/bufbuild/protovalidate/gen/tests/harness/cases/other_package/v2" - v21 "github.com/bufbuild/protovalidate/gen/tests/harness/cases/yet_another_package/v2" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" + v2 "github.com/bufbuild/protovalidate/go/gen/tests/harness/cases/other_package/v2" + v21 "github.com/bufbuild/protovalidate/go/gen/tests/harness/cases/yet_another_package/v2" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -1144,22 +1144,22 @@ var file_tests_harness_cases_v2_enums_proto_rawDesc = []byte{ 0x53, 0x54, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x41, 0x4c, 0x49, 0x41, 0x53, 0x5f, 0x42, 0x45, 0x54, 0x41, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x15, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x41, 0x4c, 0x49, 0x41, 0x53, 0x5f, 0x47, 0x41, 0x4d, 0x4d, 0x41, 0x10, 0x03, 0x1a, - 0x02, 0x10, 0x01, 0x42, 0xe9, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x02, 0x10, 0x01, 0x42, 0xec, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0a, 0x45, 0x6e, 0x75, 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, + 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, - 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, - 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, - 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, - 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, - 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, - 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, - 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, - 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, + 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, + 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, + 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, + 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, + 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, + 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, + 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/filename-with-dash.pb.go b/go/gen/tests/harness/cases/v2/filename-with-dash.pb.go similarity index 76% rename from gen/tests/harness/cases/v2/filename-with-dash.pb.go rename to go/gen/tests/harness/cases/v2/filename-with-dash.pb.go index 5da51887..c458f481 100644 --- a/gen/tests/harness/cases/v2/filename-with-dash.pb.go +++ b/go/gen/tests/harness/cases/v2/filename-with-dash.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -43,23 +43,23 @@ var file_tests_harness_cases_v2_filename_with_dash_proto_rawDesc = []byte{ 0x6f, 0x12, 0x16, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0xf4, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0xf7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x15, 0x46, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x57, - 0x69, 0x74, 0x68, 0x44, 0x61, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, + 0x69, 0x74, 0x68, 0x44, 0x61, 0x73, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, - 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, - 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, - 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, - 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, - 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, - 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, - 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, + 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, + 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, + 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, + 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, + 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, + 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_tests_harness_cases_v2_filename_with_dash_proto_goTypes = []interface{}{} diff --git a/gen/tests/harness/cases/v2/kitchen_sink.pb.go b/go/gen/tests/harness/cases/v2/kitchen_sink.pb.go similarity index 95% rename from gen/tests/harness/cases/v2/kitchen_sink.pb.go rename to go/gen/tests/harness/cases/v2/kitchen_sink.pb.go index 939a3068..43de750d 100644 --- a/gen/tests/harness/cases/v2/kitchen_sink.pb.go +++ b/go/gen/tests/harness/cases/v2/kitchen_sink.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" @@ -431,22 +431,23 @@ var file_tests_harness_cases_v2_kitchen_sink_proto_rawDesc = []byte{ 0x0a, 0x15, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x58, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x19, 0x0a, 0x15, 0x43, 0x4f, 0x4d, 0x50, 0x4c, 0x45, 0x58, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x54, - 0x57, 0x4f, 0x10, 0x02, 0x42, 0xef, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, + 0x57, 0x4f, 0x10, 0x02, 0x42, 0xf2, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x10, 0x4b, 0x69, 0x74, 0x63, 0x68, 0x65, 0x6e, 0x53, 0x69, 0x6e, 0x6b, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, - 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, - 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, - 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, - 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, - 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, - 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, - 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, - 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, - 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, + 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, + 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, + 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, + 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, + 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, + 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, + 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, + 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/maps.pb.go b/go/gen/tests/harness/cases/v2/maps.pb.go similarity index 97% rename from gen/tests/harness/cases/v2/maps.pb.go rename to go/gen/tests/harness/cases/v2/maps.pb.go index 9be54f55..7f8e0b68 100644 --- a/gen/tests/harness/cases/v2/maps.pb.go +++ b/go/gen/tests/harness/cases/v2/maps.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -902,22 +902,22 @@ var file_tests_harness_cases_v2_maps_proto_rawDesc = []byte{ 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x42, 0xe8, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x02, 0x38, 0x01, 0x42, 0xeb, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x09, 0x4d, 0x61, 0x70, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, + 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, - 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, - 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, - 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, - 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, - 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, - 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, - 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, - 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, + 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, + 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, + 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, + 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, + 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, + 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, + 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, + 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, + 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/messages.pb.go b/go/gen/tests/harness/cases/v2/messages.pb.go similarity index 95% rename from gen/tests/harness/cases/v2/messages.pb.go rename to go/gen/tests/harness/cases/v2/messages.pb.go index b12efb13..66d1dd08 100644 --- a/gen/tests/harness/cases/v2/messages.pb.go +++ b/go/gen/tests/harness/cases/v2/messages.pb.go @@ -21,8 +21,8 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" - v2 "github.com/bufbuild/protovalidate/gen/tests/harness/cases/other_package/v2" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" + v2 "github.com/bufbuild/protovalidate/go/gen/tests/harness/cases/other_package/v2" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -623,23 +623,23 @@ var file_tests_harness_cases_v2_messages_proto_rawDesc = []byte{ 0x65, 0x73, 0x74, 0x4d, 0x73, 0x67, 0x42, 0x09, 0xfa, 0xf7, 0x18, 0x05, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, 0x0d, 0x0a, 0x03, 0x6f, 0x6e, 0x65, 0x12, 0x06, 0xfa, 0xf7, 0x18, 0x02, 0x08, 0x01, 0x22, 0x15, 0x0a, 0x13, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x33, 0x64, 0x49, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x42, 0xec, + 0x67, 0x65, 0x57, 0x69, 0x74, 0x68, 0x33, 0x64, 0x49, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x42, 0xef, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0d, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, - 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, - 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, - 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, - 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, - 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, - 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, - 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, + 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, + 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, + 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, + 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, + 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, + 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, + 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/numbers.pb.go b/go/gen/tests/harness/cases/v2/numbers.pb.go similarity index 99% rename from gen/tests/harness/cases/v2/numbers.pb.go rename to go/gen/tests/harness/cases/v2/numbers.pb.go index c2498c8a..dcc9156f 100644 --- a/gen/tests/harness/cases/v2/numbers.pb.go +++ b/go/gen/tests/harness/cases/v2/numbers.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -7881,22 +7881,22 @@ var file_tests_harness_cases_v2_numbers_proto_rawDesc = []byte{ 0x34, 0x4c, 0x54, 0x45, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x12, 0x1f, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x08, 0xfa, 0xf7, 0x18, 0x04, 0x22, 0x02, 0x18, 0x40, 0x48, 0x00, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x42, 0x06, 0x0a, - 0x04, 0x5f, 0x76, 0x61, 0x6c, 0x42, 0xeb, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, + 0x04, 0x5f, 0x76, 0x61, 0x6c, 0x42, 0xee, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0c, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, - 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, - 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, - 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, - 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, - 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, - 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, - 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, + 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, + 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, + 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, + 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, + 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/oneofs.pb.go b/go/gen/tests/harness/cases/v2/oneofs.pb.go similarity index 94% rename from gen/tests/harness/cases/v2/oneofs.pb.go rename to go/gen/tests/harness/cases/v2/oneofs.pb.go index 282a0bec..51048a24 100644 --- a/gen/tests/harness/cases/v2/oneofs.pb.go +++ b/go/gen/tests/harness/cases/v2/oneofs.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -501,23 +501,23 @@ var file_tests_harness_cases_v2_oneofs_proto_rawDesc = []byte{ 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0c, 0xfa, 0xf7, 0x18, 0x08, 0x7a, 0x06, 0x10, 0x03, 0x18, 0x05, 0x70, 0x01, 0x48, 0x00, 0x52, 0x01, 0x79, 0x12, 0x1e, 0x0a, 0x01, 0x7a, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0e, 0xfa, 0xf7, 0x18, 0x0a, 0x1a, 0x08, 0x18, 0x80, 0x01, 0x28, 0x80, - 0x02, 0x40, 0x01, 0x48, 0x00, 0x52, 0x01, 0x7a, 0x42, 0x03, 0x0a, 0x01, 0x6f, 0x42, 0xea, 0x01, + 0x02, 0x40, 0x01, 0x48, 0x00, 0x52, 0x01, 0x7a, 0x42, 0x03, 0x0a, 0x01, 0x6f, 0x42, 0xed, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0b, 0x4f, 0x6e, - 0x65, 0x6f, 0x66, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, + 0x65, 0x6f, 0x66, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, - 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, - 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, - 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, - 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, - 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, - 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, - 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, + 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, + 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, + 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, + 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, + 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/repeated.pb.go b/go/gen/tests/harness/cases/v2/repeated.pb.go similarity index 98% rename from gen/tests/harness/cases/v2/repeated.pb.go rename to go/gen/tests/harness/cases/v2/repeated.pb.go index 63f24d66..1a088028 100644 --- a/gen/tests/harness/cases/v2/repeated.pb.go +++ b/go/gen/tests/harness/cases/v2/repeated.pb.go @@ -21,8 +21,8 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" - v2 "github.com/bufbuild/protovalidate/gen/tests/harness/cases/other_package/v2" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" + v2 "github.com/bufbuild/protovalidate/go/gen/tests/harness/cases/other_package/v2" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" @@ -1455,23 +1455,23 @@ var file_tests_harness_cases_v2_repeated_proto_rawDesc = []byte{ 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x17, 0x0a, 0x13, 0x41, 0x4e, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x41, 0x4e, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x58, 0x10, 0x01, 0x12, 0x0d, 0x0a, - 0x09, 0x41, 0x4e, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x59, 0x10, 0x02, 0x42, 0xec, 0x01, 0x0a, + 0x09, 0x41, 0x4e, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x59, 0x10, 0x02, 0x42, 0xef, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0d, 0x52, 0x65, 0x70, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, - 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, - 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, - 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, - 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, - 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, - 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, + 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, + 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, + 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, + 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, + 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/strings.pb.go b/go/gen/tests/harness/cases/v2/strings.pb.go similarity index 98% rename from gen/tests/harness/cases/v2/strings.pb.go rename to go/gen/tests/harness/cases/v2/strings.pb.go index c9ecbd40..6da123b5 100644 --- a/gen/tests/harness/cases/v2/strings.pb.go +++ b/go/gen/tests/harness/cases/v2/strings.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -1763,23 +1763,23 @@ var file_tests_harness_cases_v2_strings_proto_rawDesc = []byte{ 0x76, 0x61, 0x6c, 0x22, 0x38, 0x0a, 0x0d, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x49, 0x6e, 0x4f, 0x6e, 0x65, 0x4f, 0x66, 0x12, 0x20, 0x0a, 0x03, 0x62, 0x61, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0c, 0xfa, 0xf7, 0x18, 0x08, 0x72, 0x06, 0x52, 0x01, 0x61, 0x52, 0x01, 0x62, 0x48, - 0x00, 0x52, 0x03, 0x62, 0x61, 0x72, 0x42, 0x05, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x42, 0xeb, 0x01, + 0x00, 0x52, 0x03, 0x62, 0x61, 0x72, 0x42, 0x05, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x42, 0xee, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0c, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, + 0x72, 0x69, 0x6e, 0x67, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, - 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, - 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, - 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, - 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, - 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, - 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, + 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, + 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, + 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, + 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, + 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/wkt_any.pb.go b/go/gen/tests/harness/cases/v2/wkt_any.pb.go similarity index 91% rename from gen/tests/harness/cases/v2/wkt_any.pb.go rename to go/gen/tests/harness/cases/v2/wkt_any.pb.go index 5db981c4..db33d5c5 100644 --- a/gen/tests/harness/cases/v2/wkt_any.pb.go +++ b/go/gen/tests/harness/cases/v2/wkt_any.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" @@ -255,22 +255,22 @@ var file_tests_harness_cases_v2_wkt_any_proto_rawDesc = []byte{ 0x65, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x61, 0x70, 0x69, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, - 0xea, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, + 0xed, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0b, - 0x57, 0x6b, 0x74, 0x41, 0x6e, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, + 0x57, 0x6b, 0x74, 0x41, 0x6e, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, - 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, - 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, - 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, - 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, - 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, + 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, + 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, + 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, + 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/wkt_duration.pb.go b/go/gen/tests/harness/cases/v2/wkt_duration.pb.go similarity index 96% rename from gen/tests/harness/cases/v2/wkt_duration.pb.go rename to go/gen/tests/harness/cases/v2/wkt_duration.pb.go index 00aa89f7..e2ca1e5e 100644 --- a/gen/tests/harness/cases/v2/wkt_duration.pb.go +++ b/go/gen/tests/harness/cases/v2/wkt_duration.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" durationpb "google.golang.org/protobuf/types/known/durationpb" @@ -786,23 +786,23 @@ var file_tests_harness_cases_v2_wkt_duration_proto_rawDesc = []byte{ 0xf7, 0x18, 0x07, 0xaa, 0x01, 0x04, 0x22, 0x02, 0x08, 0x01, 0x52, 0x0b, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x61, 0x6c, 0x12, 0x21, 0x0a, 0x07, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x42, 0x08, 0xfa, 0xf7, 0x18, 0x04, 0x1a, 0x02, - 0x20, 0x10, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x42, 0xef, 0x01, 0x0a, 0x1a, 0x63, + 0x20, 0x10, 0x52, 0x06, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x42, 0xf2, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x10, 0x57, 0x6b, 0x74, 0x44, 0x75, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, - 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, - 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, - 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, - 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, - 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, + 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, + 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, + 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, + 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/wkt_nested.pb.go b/go/gen/tests/harness/cases/v2/wkt_nested.pb.go similarity index 90% rename from gen/tests/harness/cases/v2/wkt_nested.pb.go rename to go/gen/tests/harness/cases/v2/wkt_nested.pb.go index 677b5b05..6ddc0c30 100644 --- a/gen/tests/harness/cases/v2/wkt_nested.pb.go +++ b/go/gen/tests/harness/cases/v2/wkt_nested.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -200,23 +200,23 @@ var file_tests_harness_cases_v2_wkt_nested_proto_rawDesc = []byte{ 0x8a, 0x01, 0x02, 0x10, 0x01, 0x52, 0x05, 0x74, 0x68, 0x72, 0x65, 0x65, 0x1a, 0x2e, 0x0a, 0x0d, 0x57, 0x6b, 0x74, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x54, 0x68, 0x72, 0x65, 0x65, 0x12, 0x1d, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0xf7, 0x18, - 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x42, 0xed, 0x01, 0x0a, + 0x05, 0x72, 0x03, 0xb0, 0x01, 0x01, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x42, 0xf0, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0e, 0x57, 0x6b, 0x74, - 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, + 0x4e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, - 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, - 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, - 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, - 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, - 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, - 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, + 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, + 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, + 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, + 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, + 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, + 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, + 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/wkt_timestamp.pb.go b/go/gen/tests/harness/cases/v2/wkt_timestamp.pb.go similarity index 97% rename from gen/tests/harness/cases/v2/wkt_timestamp.pb.go rename to go/gen/tests/harness/cases/v2/wkt_timestamp.pb.go index 52e0c49a..e559fd49 100644 --- a/gen/tests/harness/cases/v2/wkt_timestamp.pb.go +++ b/go/gen/tests/harness/cases/v2/wkt_timestamp.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" timestamppb "google.golang.org/protobuf/types/known/timestamppb" @@ -876,23 +876,23 @@ var file_tests_harness_cases_v2_wkt_timestamp_proto_rawDesc = []byte{ 0x12, 0x3c, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x0e, 0xfa, 0xf7, 0x18, 0x0a, 0xb2, - 0x01, 0x07, 0x40, 0x01, 0x4a, 0x03, 0x08, 0x90, 0x1c, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, 0xf0, + 0x01, 0x07, 0x40, 0x01, 0x4a, 0x03, 0x08, 0x90, 0x1c, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x42, 0xf3, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x11, 0x57, 0x6b, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, + 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, - 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, 0x32, - 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, 0x02, - 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, - 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, - 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, - 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, - 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x56, - 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, + 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, + 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, + 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, + 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, + 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, + 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, + 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/v2/wkt_wrappers.pb.go b/go/gen/tests/harness/cases/v2/wkt_wrappers.pb.go similarity index 96% rename from gen/tests/harness/cases/v2/wkt_wrappers.pb.go rename to go/gen/tests/harness/cases/v2/wkt_wrappers.pb.go index 05bf8def..a226a1ab 100644 --- a/gen/tests/harness/cases/v2/wkt_wrappers.pb.go +++ b/go/gen/tests/harness/cases/v2/wkt_wrappers.pb.go @@ -21,7 +21,7 @@ package casesv2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" @@ -774,22 +774,22 @@ var file_tests_harness_cases_v2_wkt_wrappers_proto_rawDesc = []byte{ 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x10, 0xfa, 0xf7, 0x18, 0x0c, 0x8a, 0x01, 0x02, 0x10, 0x01, 0x0a, 0x05, 0x25, 0x00, 0x00, 0x00, 0x00, 0x52, 0x03, 0x76, 0x61, 0x6c, - 0x42, 0xef, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, + 0x42, 0xf2, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x10, 0x57, 0x6b, 0x74, 0x57, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, - 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x76, - 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x43, 0xaa, - 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, - 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, - 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, - 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, - 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, - 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, - 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, + 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, + 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x61, 0x73, 0x65, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, + 0x48, 0x43, 0xaa, 0x02, 0x16, 0x54, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, + 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x54, 0x65, + 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, + 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, + 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, + 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x54, 0x65, 0x73, 0x74, + 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, + 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/cases/yet_another_package/v2/embed2.pb.go b/go/gen/tests/harness/cases/yet_another_package/v2/embed2.pb.go similarity index 82% rename from gen/tests/harness/cases/yet_another_package/v2/embed2.pb.go rename to go/gen/tests/harness/cases/yet_another_package/v2/embed2.pb.go index 62ad3f43..71905553 100644 --- a/gen/tests/harness/cases/yet_another_package/v2/embed2.pb.go +++ b/go/gen/tests/harness/cases/yet_another_package/v2/embed2.pb.go @@ -21,7 +21,7 @@ package yet_another_packagev2 import ( - _ "github.com/bufbuild/protovalidate/gen/buf/validate" + _ "github.com/bufbuild/protovalidate/go/gen/buf/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -146,30 +146,30 @@ var file_tests_harness_cases_yet_another_package_v2_embed2_proto_rawDesc = []byt 0x72, 0x61, 0x74, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x16, 0x45, 0x4e, 0x55, 0x4d, 0x45, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x55, 0x4d, 0x45, 0x52, 0x41, 0x54, 0x45, 0x44, 0x5f, - 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x01, 0x42, 0xea, 0x02, 0x0a, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, + 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x01, 0x42, 0xed, 0x02, 0x0a, 0x2e, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x79, 0x65, 0x74, 0x5f, 0x61, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x76, 0x32, 0x42, 0x0b, 0x45, 0x6d, 0x62, 0x65, - 0x64, 0x32, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x66, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x64, 0x32, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x69, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, - 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x63, - 0x61, 0x73, 0x65, 0x73, 0x2f, 0x79, 0x65, 0x74, 0x5f, 0x61, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, - 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x79, 0x65, 0x74, 0x5f, - 0x61, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x76, - 0x32, 0xa2, 0x02, 0x04, 0x54, 0x48, 0x43, 0x59, 0xaa, 0x02, 0x28, 0x54, 0x65, 0x73, 0x74, 0x73, - 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, 0x73, 0x2e, 0x59, - 0x65, 0x74, 0x41, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x2e, 0x56, 0x32, 0xca, 0x02, 0x28, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, - 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x59, 0x65, 0x74, 0x41, 0x6e, 0x6f, - 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, 0x32, 0xe2, 0x02, - 0x34, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, - 0x61, 0x73, 0x65, 0x73, 0x5c, 0x59, 0x65, 0x74, 0x41, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x50, - 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x2c, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, - 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, 0x3a, 0x3a, 0x59, - 0x65, 0x74, 0x41, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, - 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, + 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x2f, 0x63, 0x61, 0x73, 0x65, 0x73, 0x2f, 0x79, 0x65, 0x74, 0x5f, 0x61, 0x6e, 0x6f, 0x74, + 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x79, + 0x65, 0x74, 0x5f, 0x61, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, + 0x67, 0x65, 0x76, 0x32, 0xa2, 0x02, 0x04, 0x54, 0x48, 0x43, 0x59, 0xaa, 0x02, 0x28, 0x54, 0x65, + 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x43, 0x61, 0x73, 0x65, + 0x73, 0x2e, 0x59, 0x65, 0x74, 0x41, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x28, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, + 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x59, 0x65, 0x74, + 0x41, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, + 0x32, 0xe2, 0x02, 0x34, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x5c, 0x43, 0x61, 0x73, 0x65, 0x73, 0x5c, 0x59, 0x65, 0x74, 0x41, 0x6e, 0x6f, 0x74, 0x68, + 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x2c, 0x54, 0x65, 0x73, 0x74, 0x73, + 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, 0x43, 0x61, 0x73, 0x65, 0x73, + 0x3a, 0x3a, 0x59, 0x65, 0x74, 0x41, 0x6e, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/gen/tests/harness/v2/harness.pb.go b/go/gen/tests/harness/v2/harness.pb.go similarity index 90% rename from gen/tests/harness/v2/harness.pb.go rename to go/gen/tests/harness/v2/harness.pb.go index b08b83a7..b4ef7bc7 100644 --- a/gen/tests/harness/v2/harness.pb.go +++ b/go/gen/tests/harness/v2/harness.pb.go @@ -183,20 +183,20 @@ var file_tests_harness_v2_harness_proto_rawDesc = []byte{ 0x75, 0x72, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, - 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x42, 0xc8, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, + 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x42, 0xcb, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x76, 0x32, 0x42, 0x0c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, + 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x62, 0x75, 0x66, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x68, 0x61, - 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, - 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x58, 0xaa, 0x02, 0x10, 0x54, 0x65, 0x73, 0x74, 0x73, - 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x10, 0x54, 0x65, - 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x56, 0x32, 0xe2, 0x02, - 0x1c, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x56, - 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x12, - 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x3a, 0x3a, - 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x74, 0x65, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, + 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x76, 0x32, 0x3b, 0x68, 0x61, 0x72, 0x6e, + 0x65, 0x73, 0x73, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x54, 0x48, 0x58, 0xaa, 0x02, 0x10, 0x54, 0x65, + 0x73, 0x74, 0x73, 0x2e, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2e, 0x56, 0x32, 0xca, 0x02, + 0x10, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x5c, 0x56, + 0x32, 0xe2, 0x02, 0x1c, 0x54, 0x65, 0x73, 0x74, 0x73, 0x5c, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x12, 0x54, 0x65, 0x73, 0x74, 0x73, 0x3a, 0x3a, 0x48, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/go/go.mod b/go/go.mod new file mode 100644 index 00000000..e207a997 --- /dev/null +++ b/go/go.mod @@ -0,0 +1,22 @@ +module github.com/bufbuild/protovalidate/go + +go 1.18 + +require ( + github.com/google/cel-go v0.14.0 + github.com/stretchr/testify v1.8.2 + golang.org/x/sync v0.1.0 + google.golang.org/protobuf v1.30.0 +) + +require ( + github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stoewer/go-strcase v1.3.0 // indirect + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/text v0.9.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go/go.sum similarity index 60% rename from go.sum rename to go/go.sum index 4244b831..f71eb56e 100644 --- a/go.sum +++ b/go/go.sum @@ -1,5 +1,5 @@ -github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= -github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 h1:X8MJ0fnN5FPdcGF5Ij2/OW+HgiJrRg3AfHAx1PJtIzM= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -11,31 +11,30 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= +github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= -golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= -google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= -google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go/registry.go b/go/registry.go new file mode 100644 index 00000000..ccd51a90 --- /dev/null +++ b/go/registry.go @@ -0,0 +1,267 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protovalidate + +import ( + "fmt" + + "github.com/bufbuild/protovalidate/go/gen/buf/validate" + "github.com/google/cel-go/cel" + celext "github.com/google/cel-go/ext" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" +) + +type registry struct { + baseEnv *cel.Env + sf singleFlight[protoreflect.FullName, *messageEvaluator] + messageEvaluators syncMap[protoreflect.FullName, *messageEvaluator] + inflightEvaluators syncMap[protoreflect.FullName, *messageEvaluator] + // standardConstraints syncMap[protoreflect.FullName, cel.Program] +} + +func newRegistry() *registry { + env, _ := cel.NewEnv( + cel.CrossTypeNumericComparisons(true), + celext.Strings(), + ) + return ®istry{baseEnv: env} +} + +func (r *registry) loadOrBuild(desc protoreflect.MessageDescriptor) *messageEvaluator { + if eval, ok := r.messageEvaluators.Load(desc.FullName()); ok { + return eval + } + + eval, _, _ := r.sf.Do(desc.FullName(), func() (*messageEvaluator, error) { + return r.build(desc), nil + }) + return eval +} + +func (r *registry) inflightLoadOrBuild(desc protoreflect.MessageDescriptor) *messageEvaluator { + eval, ok := r.inflightEvaluators.Load(desc.FullName()) + if ok { + return eval + } + return r.loadOrBuild(desc) +} + +func (r *registry) build(desc protoreflect.MessageDescriptor) *messageEvaluator { + fullName := desc.FullName() + msgEval := &messageEvaluator{} + defer r.messageEvaluators.Store(fullName, msgEval) + r.inflightEvaluators.Store(fullName, msgEval) + defer r.inflightEvaluators.Delete(fullName) + if r.buildMessageExpressions(msgEval, desc); msgEval.err != nil { + return msgEval + } + if r.buildFields(msgEval, desc); msgEval.err != nil { + return msgEval + } + return msgEval +} + +func (r *registry) buildMessageExpressions(msgEval *messageEvaluator, desc protoreflect.MessageDescriptor) { + constraints, ok := proto.GetExtension(desc.Options(), validate.E_Message).(*validate.MessageConstraints) + if !ok || constraints.GetDisabled() || len(constraints.GetCel()) == 0 { + return + } + + compiledExprs, err := r.compileExprs(constraints.GetCel(), + cel.TypeDescs(desc.ParentFile()), + cel.Variable("this", cel.ObjectType(string(desc.FullName()))), + ) + if err != nil { + msgEval.err = err + return + } + + msgEval.constraints = append( + msgEval.constraints, + messageExpressionEvaluator{ + exprs: compiledExprs, + }, + ) +} + +func (r *registry) buildFields(msgEval *messageEvaluator, desc protoreflect.MessageDescriptor) { + fields := desc.Fields() + for i := 0; i < fields.Len(); i++ { + fdesc := fields.Get(i) + switch { + case fdesc.IsMap(): + msgEval.err = CompilationError{ + cause: fmt.Errorf("map field %s is currently unsupported", fdesc.FullName()), + } + case fdesc.IsList(): + msgEval.err = CompilationError{ + cause: fmt.Errorf("repeated field %s is currently unsupported", fdesc.FullName()), + } + case fdesc.Kind() == protoreflect.MessageKind: + r.buildMessageField(msgEval, fdesc) + default: + r.buildScalarField(msgEval, fdesc) + } + if msgEval.err != nil { + return + } + } +} + +func (r *registry) buildMessageField(msgEval *messageEvaluator, fdesc protoreflect.FieldDescriptor) { + fldEval := messageFieldEvaluator{field: fdesc} + + fldEval.msgEval = r.inflightLoadOrBuild(fdesc.Message()) + if err := fldEval.msgEval.err; err != nil { + msgEval.err = CompilationError{ + cause: fmt.Errorf("failed to compile embedded type %s: %w", + fdesc.Message().FullName(), err), + } + return + } + + constraints, _ := proto.GetExtension(fdesc.Options(), validate.E_Field).(*validate.FieldConstraints) + fldEval.required = constraints.GetMessage().GetRequired() + fldEval.skipped = constraints.GetMessage().GetSkipped() + + // TODO: check for WKTs + + compiledExprs, err := r.compileExprs(constraints.GetCel(), + cel.TypeDescs(fdesc.ParentFile()), + cel.Variable("this", cel.ObjectType(string(fdesc.Message().FullName()))), + ) + if err != nil { + msgEval.err = err + return + } + fldEval.exprs = compiledExprs + msgEval.constraints = append(msgEval.constraints, fldEval) +} + +func (r *registry) buildScalarField(msgEval *messageEvaluator, fdesc protoreflect.FieldDescriptor) { + fldEval := fieldExpressionEvaluator{ + field: fdesc, + } + + // TODO: standard constraints + + constraints, _ := proto.GetExtension(fdesc.Options(), validate.E_Field).(*validate.FieldConstraints) + compiledExprs, err := r.compileExprs(constraints.GetCel(), + cel.Variable("this", protoKindsToCEL[fdesc.Kind()]), + ) + if err != nil { + msgEval.err = err + return + } + fldEval.exprs = compiledExprs + + if len(fldEval.exprs) > 0 { + msgEval.constraints = append(msgEval.constraints, fldEval) + } +} + +func (r *registry) compileExprs(exprs []*validate.Constraint, envOpts ...cel.EnvOption) ([]compiledExpression, error) { + if len(exprs) == 0 { + return nil, nil + } + + env, err := r.baseEnv.Extend(envOpts...) + if err != nil { + return nil, CompilationError{ + cause: fmt.Errorf("failed to extend base environment: %w", err), + } + } + + compiledExprs := make([]compiledExpression, len(exprs)) + for i, expr := range exprs { + compiledExprs[i].source = expr + ast, issues := env.Compile(expr.Expression) + if err = issues.Err(); err != nil { + return nil, CompilationError{ + cause: fmt.Errorf("failed to compile expression %s: %w", expr.Id, err), + } + } + + compiledExprs[i].program, err = env.Program(ast, cel.EvalOptions( + cel.OptOptimize, + cel.OptCheckStringFormat, + )) + if err != nil { + return nil, CompilationError{ + cause: fmt.Errorf("failed to compile program %s: %w", expr.Id, err), + } + } + } + + return compiledExprs, nil +} + +var ( + protoKindsToCEL = map[protoreflect.Kind]*cel.Type{ + protoreflect.FloatKind: cel.DoubleType, + protoreflect.DoubleKind: cel.DoubleType, + protoreflect.Int32Kind: cel.IntType, + protoreflect.Int64Kind: cel.IntType, + protoreflect.Uint32Kind: cel.UintType, + protoreflect.Uint64Kind: cel.UintType, + protoreflect.Sint32Kind: cel.IntType, + protoreflect.Sint64Kind: cel.IntType, + protoreflect.Fixed32Kind: cel.UintType, + protoreflect.Fixed64Kind: cel.UintType, + protoreflect.Sfixed32Kind: cel.IntType, + protoreflect.Sfixed64Kind: cel.IntType, + protoreflect.BoolKind: cel.BoolType, + protoreflect.StringKind: cel.StringType, + protoreflect.BytesKind: cel.BytesType, + protoreflect.EnumKind: cel.IntType, + } + // + // fieldRules = (&validate.FieldConstraints{}).ProtoReflect().Descriptor() + // expectedStdConstraints = map[protoreflect.Kind]protoreflect.FieldDescriptor{ + // protoreflect.FloatKind: fieldRules.Fields().ByName("float"), + // protoreflect.DoubleKind: fieldRules.Fields().ByName("double"), + // protoreflect.Int32Kind: fieldRules.Fields().ByName("int32"), + // protoreflect.Int64Kind: fieldRules.Fields().ByName("int64"), + // protoreflect.Uint32Kind: fieldRules.Fields().ByName("uint32"), + // protoreflect.Uint64Kind: fieldRules.Fields().ByName("uint64"), + // protoreflect.Sint32Kind: fieldRules.Fields().ByName("sint32"), + // protoreflect.Sint64Kind: fieldRules.Fields().ByName("sint64"), + // protoreflect.Fixed32Kind: fieldRules.Fields().ByName("fixed32"), + // protoreflect.Fixed64Kind: fieldRules.Fields().ByName("fixed64"), + // protoreflect.Sfixed32Kind: fieldRules.Fields().ByName("sfixed32"), + // protoreflect.Sfixed64Kind: fieldRules.Fields().ByName("sfixed64"), + // protoreflect.BoolKind: fieldRules.Fields().ByName("bool"), + // protoreflect.StringKind: fieldRules.Fields().ByName("string"), + // protoreflect.BytesKind: fieldRules.Fields().ByName("bytes"), + // protoreflect.EnumKind: fieldRules.Fields().ByName("enum"), + // } + // expectedWrapperConstraints = map[protoreflect.FullName]protoreflect.FieldDescriptor{ + // "google.protobuf.BoolValue": fieldRules.Fields().ByName("bool"), + // "google.protobuf.BytesValue": fieldRules.Fields().ByName("bytes"), + // "google.protobuf.DoubleValue": fieldRules.Fields().ByName("double"), + // "google.protobuf.FloatValue": fieldRules.Fields().ByName("float"), + // "google.protobuf.Int32Value": fieldRules.Fields().ByName("int32"), + // "google.protobuf.Int64Value": fieldRules.Fields().ByName("int64"), + // "google.protobuf.StringValue": fieldRules.Fields().ByName("string"), + // "google.protobuf.UInt32Value": fieldRules.Fields().ByName("uint32"), + // "google.protobuf.UInt64Value": fieldRules.Fields().ByName("uint64"), + // } + // expectedWKTConstraints = map[protoreflect.FullName]protoreflect.FieldDescriptor{ + // "google.protobuf.Any": fieldRules.Fields().ByName("any"), + // "google.protobuf.Duration": fieldRules.Fields().ByName("duration"), + // "google.protobuf.Timestamp": fieldRules.Fields().ByName("timestamp"), + // } +) diff --git a/sync_map.go b/go/sync.go similarity index 74% rename from sync_map.go rename to go/sync.go index cec1cfcd..52dac01e 100644 --- a/sync_map.go +++ b/go/sync.go @@ -16,6 +16,8 @@ package protovalidate import ( "sync" + + "golang.org/x/sync/singleflight" ) // syncMap is a type-safe version of sync.Map, limiting the key and value to @@ -38,3 +40,18 @@ func (sm *syncMap[K, V]) Load(key K) (value V, ok bool) { func (sm *syncMap[K, V]) Store(key K, value V) { sm.inner.Store(key, value) } + +func (sm *syncMap[K, V]) Delete(key K) { + sm.inner.Delete(key) +} + +type singleFlight[K ~string, V any] struct { + inner singleflight.Group +} + +func (sf *singleFlight[K, V]) Do(key K, fn func() (V, error)) (val V, err error, shared bool) { + v, err, shared := sf.inner.Do(string(key), func() (any, error) { + return fn() + }) + return v.(V), err, shared +} diff --git a/go/validator.go b/go/validator.go new file mode 100644 index 00000000..5eec5e14 --- /dev/null +++ b/go/validator.go @@ -0,0 +1,74 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protovalidate + +import ( + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" +) + +type Validator struct{ config } + +func New(options ...ValidatorOption) *Validator { + val := &Validator{ + config: config{ + registry: newRegistry(), + }, + } + for _, opt := range options { + opt(&val.config) + } + return val +} + +func (v *Validator) Validate(msg proto.Message) error { + refl := msg.ProtoReflect() + eval := v.registry.loadOrBuild(refl.Descriptor()) + return eval.evaluate(refl, v.failFast) +} + +type config struct { + failFast bool + registry *registry +} + +type ValidatorOption func(*config) + +func WithFailFast(failFast bool) ValidatorOption { + return func(cfg *config) { + cfg.failFast = failFast + } +} + +func WithMessages(msgs ...protoreflect.MessageDescriptor) ValidatorOption { + return func(cfg *config) { + for _, msg := range msgs { + cfg.registry.loadOrBuild(msg) + } + } +} + +func WithServices(svcs ...protoreflect.ServiceDescriptor) ValidatorOption { + return func(cfg *config) { + for _, svc := range svcs { + methods := svc.Methods() + for i := 0; i < methods.Len(); i++ { + method := methods.Get(i) + cfg.registry.loadOrBuild(method.Input()) + cfg.registry.loadOrBuild(method.Output()) + } + } + } +} diff --git a/go/validator_test.go b/go/validator_test.go new file mode 100644 index 00000000..18148df4 --- /dev/null +++ b/go/validator_test.go @@ -0,0 +1,112 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package protovalidate + +import ( + "testing" + + pb "github.com/bufbuild/protovalidate/go/gen/example/v1" + "github.com/google/cel-go/cel" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestX(t *testing.T) { + input := &pb.HasMsgExprs{ + X: 1, + Y: 2, + } + + raw := "this.x < this.y" + env, err := cel.NewEnv( + cel.Types(input), + cel.Variable( + "this", cel.ObjectType(string(input.ProtoReflect().Descriptor().FullName()))), + ) + require.NoError(t, err) + ast, issues := env.Compile(raw) + require.NoError(t, issues.Err()) + prog, err := env.Program(ast) + require.NoError(t, err) + + res, _, err := prog.Eval(namedBinding{name: "this", val: input}) + require.NoError(t, err) + assert.Equal(t, true, res.Value()) +} + +func TestValidator_Validate(t *testing.T) { + t.Parallel() + + t.Run("HasMsgExprs", func(t *testing.T) { + t.Parallel() + val := New() + + tests := []struct { + msg *pb.HasMsgExprs + exErr bool + }{ + { + &pb.HasMsgExprs{X: 2, Y: 43}, + false, + }, + { + &pb.HasMsgExprs{X: 9, Y: 8}, + true, + }, + } + + for _, test := range tests { + err := val.Validate(test.msg) + if test.exErr { + assert.Error(t, err) + } else { + assert.NoError(t, err) + } + } + }) +} + +var validateErr error + +func BenchmarkValidator_Validate(b *testing.B) { + val := New(WithMessages((&pb.HasMsgExprs{}).ProtoReflect().Descriptor())) + b.ResetTimer() + b.ReportAllocs() + + b.RunParallel(func(p *testing.PB) { + var err error + msg := &pb.HasMsgExprs{ + X: 2, + Y: 43, + } + for p.Next() { + err = val.Validate(msg) + } + validateErr = err + }) +} + +func TestRecursive(t *testing.T) { + t.Parallel() + val := New() + + selfRec := &pb.SelfRecursive{X: 123, Turtle: &pb.SelfRecursive{X: 456}} + err := val.Validate(selfRec) + assert.NoError(t, err) + + loopRec := &pb.LoopRecursiveA{B: &pb.LoopRecursiveB{}} + err = val.Validate(loopRec) + assert.NoError(t, err) +} diff --git a/proto/private/example/v1/validations.proto b/proto/private/example/v1/validations.proto new file mode 100644 index 00000000..904d8c04 --- /dev/null +++ b/proto/private/example/v1/validations.proto @@ -0,0 +1,65 @@ +// Copyright 2023 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax="proto3"; + +package example.v1; + +import "buf/validate/validate.proto"; + +message HasMsgExprs { + option (buf.validate.message).cel = { + id: "x_lt_y", + message: "x must be less than y", + expression: "this.x < this.y", + }; + + option (buf.validate.message).cel = { + id: "y_gt_42", + expression: "this.y > 42 ? ''" + ": 'y must be greater than 42'", + }; + + int32 x = 1 [ + (buf.validate.field).cel = { + id: "x_even", + message: "x must be even", + expression: "this % 2 == 0" + }, + (buf.validate.field).cel = { + id: "x_coprime_3", + expression: "this % 3 != 0 ? ''" + ": 'x must not be divisible by 3'", + }]; + int32 y = 2; +} + +message SelfRecursive { + option (buf.validate.message).cel = { + id: "unique_turtles", + message: "adjacent turtles must be unique", + expression: "this.x != this.turtle.x", + }; + + int32 x = 1; + SelfRecursive turtle = 2; +} + +message LoopRecursiveA { + LoopRecursiveB b = 1; +} + +message LoopRecursiveB { + LoopRecursiveA a = 1; +} \ No newline at end of file diff --git a/proto/public/buf/validate/expression.proto b/proto/public/buf/validate/expression.proto index db7fa7d6..8635930c 100644 --- a/proto/public/buf/validate/expression.proto +++ b/proto/public/buf/validate/expression.proto @@ -33,3 +33,13 @@ message Constraint { // expression evaluates to false or a non-empty string. string expression = 3; } + +message Violations { + repeated Violation violations = 1; +} + +message Violation { + string field_path = 1; + string constraint_id = 2; + string message = 3; +} \ No newline at end of file diff --git a/registry.go b/registry.go deleted file mode 100644 index e9dac81e..00000000 --- a/registry.go +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright 2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package protovalidate - -import ( - "fmt" - "strings" - - "github.com/bufbuild/protovalidate/gen/buf/validate" - - "github.com/google/cel-go/cel" - typespb "github.com/google/cel-go/common/types/pb" - celext "github.com/google/cel-go/ext" - "golang.org/x/sync/singleflight" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" -) - -// Registry contains a cache of validation rules. -type Registry struct { - sf singleflight.Group - rulesCache syncMap[protoreflect.FullName, MessageRules] -} - -// LoadOrBuildRules is a thread-safe method to build validation rules for a message. -func (c *Registry) LoadOrBuildRules(message protoreflect.Message) MessageRules { - descriptor := message.Descriptor() - if rules, ok := c.rulesCache.Load(descriptor.FullName()); ok { - return rules - } - - res, _, _ := c.sf.Do(string(descriptor.FullName()), func() (any, error) { - return c.buildRules(descriptor, message), nil - }) - - return res.(MessageRules) -} - -// buildRules constructs validation rules for a message descriptor. -func (c *Registry) buildRules( - descriptor protoreflect.MessageDescriptor, - message protoreflect.Message, -) MessageRules { - rules := NewMessageRules() - - c.buildMessageExpression(descriptor, message, &rules) - c.buildNestedRules(descriptor, message, &rules) - - c.rulesCache.Store(descriptor.FullName(), rules) - return rules -} - -// buildNestedRules is a helper function that constructs validation rules for all fields, including nested messages. -func (c *Registry) buildNestedRules( - descriptor protoreflect.MessageDescriptor, - message protoreflect.Message, - rules *MessageRules, -) { - for i := 0; i < descriptor.Fields().Len(); i++ { - field := descriptor.Fields().Get(i) - value := message.Get(field) - - if field.Kind() == protoreflect.MessageKind && !field.IsMap() && !field.IsList() { - nestedMessage := value.Message() - nestedDescriptor := nestedMessage.Descriptor() - c.buildNestedRules(nestedDescriptor, nestedMessage, rules) - } - - if err := c.buildFieldExpression(field, value, rules); err != nil { - rules.setErr("failed to compile field-level expression: %w", err) - } - } -} - -// buildMessageExpression constructs the message-level expression using the descriptor. -func (c *Registry) buildMessageExpression( - descriptor protoreflect.Descriptor, - message protoreflect.Message, - rules *MessageRules, -) { - options := descriptor.Options() - var expression []*validate.Constraint - - if proto.HasExtension(options, validate.E_Message) { - expression = proto.GetExtension(options, validate.E_Message).([]*validate.Constraint) - } - - prog, err := c.buildValidateExpression(expression, cel.ObjectType(string(message.Descriptor().FullName()))) - if err != nil { - rules.setErr("failed to compile message-level expression: %w", err) - } else if prog != nil { - rules.addMsgRule(prog) - } -} - -// buildFieldExpression constructs the field-level expression using the descriptor. -func (c *Registry) buildFieldExpression( - descriptor protoreflect.FieldDescriptor, - value protoreflect.Value, - rules *MessageRules, -) error { - options := descriptor.Options() - - switch { - case proto.HasExtension(options, validate.E_Field): - expression := proto.GetExtension(options, validate.E_Field).([]*validate.Constraint) - celType, err := fieldKindToCELType(descriptor.Kind()) - if err != nil { - return fmt.Errorf("failed to convert field kind to CEL type: %w", err) - } - prog, err := c.buildRulesExpression(expression, celType, value.Message().Interface()) - if err != nil { - return err - } - rules.addFieldRule(descriptor, prog, value.Message().Interface()) - return nil - - case proto.HasExtension(options, validate.E_Field): - return c.buildRulesFromExtension(descriptor, rules) - } - - return nil -} - -// buildRulesFromExtension constructs the validation rules using the field rules extension. -func (c *Registry) buildRulesFromExtension( - descriptor protoreflect.FieldDescriptor, - rules *MessageRules, -) error { - fieldRules := proto.GetExtension(descriptor.Options(), validate.E_Field).(*validate.FieldConstraints) - msg := fieldRules.ProtoReflect() - oneOfDescriptor := msg.Descriptor().Oneofs().ByName("type") - oneOf := msg.WhichOneof(oneOfDescriptor) - oneOfVal := msg.Get(oneOf) - message := oneOfVal.Message() - - if proto.HasExtension(message.Descriptor().Options(), validate.E_Message) { - expression := proto.GetExtension(message.Descriptor().Options(), validate.E_Message).([]*validate.Constraint) - // TODO(afuller): Remove this test code. - // testExpr := ` - // has(rules.ignore_empty) && rules.ignore_empty && this.size() == 0 ? '' : - // '' - // ` - // expression.Expression = &testExpr - celType, err := fieldKindToCELType(descriptor.Kind()) - if err != nil { - return fmt.Errorf("failed to convert field kind to CEL type: %w", err) - } - - prog, err := c.buildRulesExpression(expression, celType, message.Interface()) - if err != nil { - return fmt.Errorf("failed to build expression: %w", err) - } - rules.addFieldRule(descriptor, prog, message.Interface()) - } - - message.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool { - // do something with field - var expression []*validate.Constraint - if proto.HasExtension(fd.Options(), validate.E_Field) { - expression = proto.GetExtension(fd.Options(), validate.E_Field).([]*validate.Constraint) - } - celType, err := fieldKindToCELType(descriptor.Kind()) - if err != nil { - rules.setErr("failed to convert field kind to CEL type: %w", err) - } - prog, err := c.buildRulesExpression(expression, celType, message.Interface()) - if err != nil { - rules.setErr("failed to build expression: %w", err) - } - rules.addFieldRule(descriptor, prog, message.Interface()) - return true - }) - return nil -} - -// buildRulesExpression constructs the given expression using the descriptor, extensions, variableType, and rules message. -func (c *Registry) buildRulesExpression( - expression []*validate.Constraint, - variableType *cel.Type, - rules proto.Message, -) (cel.Program, error) { - if expression == nil { - return nil, nil - } - env, err := cel.NewEnv( - cel.EnableMacroCallTracking(), - celext.Strings(), - cel.Types(rules), - cel.Variable("this", variableType), - cel.Variable("rules", cel.ObjectType(string(rules.ProtoReflect().Descriptor().FullName()))), - ) - if err != nil { - return nil, fmt.Errorf("failed to create CEL environment: %w", err) - } - - sb := strings.Builder{} - for i, expr := range expression { - sb.WriteString(expr.GetExpression()) - if i < len(expression)-1 { - sb.WriteString(" && ") - } - } - - ast, issues := env.Compile(sb.String()) - if issues != nil { - return nil, fmt.Errorf("failed to compile expression: %w", issues.Err()) - } - - program, err := env.Program( - ast, - cel.EvalOptions(cel.OptOptimize, cel.OptPartialEval, cel.OptTrackState), - ) - if err != nil { - return nil, fmt.Errorf("failed to create CEL program: %w", err) - } - - vars, err := cel.PartialVars( - map[string]any{"rules": rules}, - cel.AttributePattern("this"), - ) - if err != nil { - return nil, fmt.Errorf("failed to create partial variables: %w", err) - } - - _, details, err := program.Eval(vars) - if err != nil { - return nil, fmt.Errorf("failed to evaluate expression: %w", err) - } - residual, err := env.ResidualAst(ast, details) - if err != nil { - return nil, fmt.Errorf("failed to create residual AST: %w", err) - } - - rprog, err := env.Program(residual) - if err != nil { - return nil, fmt.Errorf("failed to create residual program: %w", err) - } - return rprog, nil -} - -// buildValidateExpression constructs the given expression to validate 'this', using the descriptor, extensions, and variableType. -func (c *Registry) buildValidateExpression( - expression []*validate.Constraint, - variableType *cel.Type, -) (cel.Program, error) { - if expression == nil { - return nil, nil - } - env, err := cel.NewEnv( - cel.EnableMacroCallTracking(), - celext.Strings(), - cel.Variable("this", variableType), - ) - if err != nil { - return nil, fmt.Errorf("failed to create CEL environment: %w", err) - } - - sb := strings.Builder{} - for i, expr := range expression { - sb.WriteString(expr.GetExpression()) - if i < len(expression)-1 { - sb.WriteString(" && ") - } - } - - ast, issues := env.Compile(sb.String()) - if issues != nil { - return nil, fmt.Errorf("failed to compile expression: %w", issues.Err()) - } - - program, err := env.Program(ast, cel.EvalOptions(cel.OptOptimize, cel.OptTrackState)) - if err != nil { - return nil, fmt.Errorf("failed to create CEL program: %w", err) - } - - return program, nil -} - -// fieldKindToCELType converts a protoreflect.Kind to a CEL type. -func fieldKindToCELType(in protoreflect.Kind) (*cel.Type, error) { - return cel.ExprTypeToType(typespb.CheckedPrimitives[in]) -} diff --git a/rules.go b/rules.go deleted file mode 100644 index 9d32ff9c..00000000 --- a/rules.go +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package protovalidate - -import ( - "errors" - "fmt" - - "github.com/google/cel-go/cel" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" -) - -// Eval is the interface that wraps the Eval method. -type Eval interface { - Eval(value protoreflect.Value) []error -} - -// MessageRules is a collection of rules for a given message. -type MessageRules struct { - err error - msgRules []Eval - // test.cases.blah.FloatCases.val -> []Eval - fieldRules map[protoreflect.FieldDescriptor][]Eval -} - -// Eval evaluates the rules for a given message. -func (r *MessageRules) Eval(value protoreflect.Value) []error { - if r.hasErr() { - return []error{r.err} - } - var errs []error - for _, rule := range r.msgRules { - errs = append(errs, rule.Eval(value)...) - } - - msg := value.Message() - for fldDesc, rules := range r.fieldRules { - val := msg.Get(fldDesc) - for _, rule := range rules { - errs = append(errs, rule.Eval(val)...) - } - } - - return errs -} - -// CelRule is a rule that is evaluated using CEL. -type CelRule struct { - prog cel.Program - rules proto.Message -} - -// Eval evaluates the rule. -func (c CelRule) Eval(value protoreflect.Value) []error { - var m map[string]interface{} - if c.rules == nil { - m = map[string]interface{}{"this": value.Interface()} - } else { - m = map[string]interface{}{"this": value.Interface(), "rules": c.rules} - } - res, _, err := c.prog.Eval(m) - if err != nil { - return []error{err} - } - - // TODO: refine me - switch val := res.Value().(type) { - case bool: - if !val { - return []error{errors.New("validation expression resolved to false")} - } - case string: - if val != "" { - return []error{errors.New(val)} - } - default: - return []error{ - fmt.Errorf("unexpected expression result type %T", val), - } - } - - return nil -} - -// NewMessageRules returns a new MessageRules. -func NewMessageRules() MessageRules { - return MessageRules{ - fieldRules: make(map[protoreflect.FieldDescriptor][]Eval), - } -} - -// addMsgRule adds a rule for the message. -func (r *MessageRules) addMsgRule(prog cel.Program) { - r.msgRules = append(r.msgRules, CelRule{prog: prog, rules: nil}) -} - -// addFieldRule adds a rule for a given field. -func (r *MessageRules) addFieldRule(fldDesc protoreflect.FieldDescriptor, prog cel.Program, rules proto.Message) { - if prog != nil { - r.fieldRules[fldDesc] = append(r.fieldRules[fldDesc], CelRule{prog: prog, rules: rules}) - } -} - -// setErr sets the error for the message. -func (r *MessageRules) setErr(format string, a ...any) { - r.err = fmt.Errorf(format, a...) -} - -// hasErr returns true if the message has an error. -func (r *MessageRules) hasErr() bool { - return r.err != nil -} diff --git a/run.sh b/run.sh deleted file mode 100755 index 7af04544..00000000 --- a/run.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -files=(*/) -if [ $1 != "" ]; -then - files=( "$1/" ) - echo ${files[@]} -fi - -for dir in "${files[@]}"; -do - if test -d $dir - then - echo "running $dir" - dir=${dir%?}; - echo "# $dir" > $dir/README.md - echo "\`\`\`bash" >> $dir/README.md - go test ./$dir -v -race -bench=. -benchmem -cpuprofile $dir/cpu.prof -memprofile $dir/mem.prof >> $dir/README.md - echo "\`\`\`" >> $dir/README.md - go tool pprof -svg -output=$dir/cpu.svg $dir/cpu.prof && rm $dir/cpu.prof - go tool pprof -svg -output=$dir/mem.svg $dir/mem.prof && rm $dir/mem.prof - echo "## Memory profile" >> $dir/README.md - echo "![](mem.svg)" >> $dir/README.md - echo "## CPU profile" >> $dir/README.md - echo "![](cpu.svg)" >> $dir/README.md - fi -done diff --git a/validate.go b/validate.go deleted file mode 100644 index c4e10e74..00000000 --- a/validate.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package protovalidate - -import ( - "errors" - "fmt" - - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/reflect/protoreflect" -) - -// globalRegistry is the global registry of rules. -var globalRegistry = &Registry{} - -// Validate validates a protobuf message. -func Validate(msg proto.Message) error { - v := &validator{ - registry: globalRegistry, - } - errs := v.validateMessage(msg.ProtoReflect()) - if len(errs) == 0 { - return nil - } - return errors.New(fmt.Sprint(errs)) -} - -// validator is a validator. -type validator struct { - registry *Registry -} - -// validateMessage validates a protobuf message using its descriptor. -func (v *validator) validateMessage(msg protoreflect.Message) []error { - rules := v.registry.LoadOrBuildRules(msg) - return rules.Eval(protoreflect.ValueOf(msg)) -} diff --git a/validate_test.go b/validate_test.go deleted file mode 100644 index 22635d72..00000000 --- a/validate_test.go +++ /dev/null @@ -1,1376 +0,0 @@ -// Copyright 2023 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package protovalidate - -import ( - "math" - "testing" - "time" - - otherpackage "github.com/bufbuild/protovalidate/gen/tests/harness/cases/other_package/v2" - cases "github.com/bufbuild/protovalidate/gen/tests/harness/cases/v2" - yetanotherpackage "github.com/bufbuild/protovalidate/gen/tests/harness/cases/yet_another_package/v2" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" - "google.golang.org/protobuf/types/known/durationpb" - "google.golang.org/protobuf/types/known/timestamppb" - "google.golang.org/protobuf/types/known/wrapperspb" -) - -func TestValidateTestSuite(t *testing.T) { - // TODO(TCN-1559): enable all tests - // NOTE: some tests are disabled because they are not supported by - // the current implementation or have significant bugs. - if !testing.Short() { - t.Log("tests disabled by default, use -short to enable") - } else { - suite.Run(t, new(testSuite)) - } -} - -func BenchmarkValidateTestSuite(b *testing.B) { - for i := 0; i < b.N; i++ { - suite.Run(&testing.T{}, new(testSuite)) - } -} - -func runTest(testCase TestCase, test *testSuite) { - if err := Validate(testCase.message); err != nil { - if testCase.expectedFailures == 0 { - if assert.NoError(test.T(), err) { - test.passed++ - } else { - test.fails++ - } - } else { - if assert.Error(test.T(), err) { - test.passed++ - } else { - test.fails++ - } - } - } -} - -type TestCase struct { - name string - message proto.Message - expectedFailures int -} - -type testSuite struct { - suite.Suite - passed int - fails int -} - -func (test *testSuite) TestFloatCases() { - tests := []TestCase{ - {"float - none - valid", &cases.FloatNone{Val: -1.23456}, 0}, - {"float - const - valid", &cases.FloatConst{Val: 1.23}, 0}, - {"float - const - invalid", &cases.FloatConst{Val: 4.56}, 1}, - {"float - in - valid", &cases.FloatIn{Val: 7.89}, 0}, - {"float - in - invalid", &cases.FloatIn{Val: 10.11}, 1}, - {"float - not in - valid", &cases.FloatNotIn{Val: 1}, 0}, - {"float - not in - invalid", &cases.FloatNotIn{Val: 0}, 1}, - {"float - lt - valid", &cases.FloatLT{Val: -1}, 0}, - {"float - lt - invalid (equal)", &cases.FloatLT{Val: 0}, 1}, - {"float - lt - invalid", &cases.FloatLT{Val: 1}, 1}, - {"float - lte - valid", &cases.FloatLTE{Val: 63}, 0}, - {"float - lte - valid (equal)", &cases.FloatLTE{Val: 64}, 0}, - {"float - lte - invalid", &cases.FloatLTE{Val: 65}, 1}, - {"float - gt - valid", &cases.FloatGT{Val: 17}, 0}, - {"float - gt - invalid (equal)", &cases.FloatGT{Val: 16}, 1}, - {"float - gt - invalid", &cases.FloatGT{Val: 15}, 1}, - {"float - gte - valid", &cases.FloatGTE{Val: 9}, 0}, - {"float - gte - valid (equal)", &cases.FloatGTE{Val: 8}, 0}, - {"float - gte - invalid", &cases.FloatGTE{Val: 7}, 1}, - {"float - gt & lt - valid", &cases.FloatGTLT{Val: 5}, 0}, - {"float - gt & lt - invalid (above)", &cases.FloatGTLT{Val: 11}, 1}, - {"float - gt & lt - invalid (below)", &cases.FloatGTLT{Val: -1}, 1}, - {"float - gt & lt - invalid (max)", &cases.FloatGTLT{Val: 10}, 1}, - {"float - gt & lt - invalid (min)", &cases.FloatGTLT{Val: 0}, 1}, - {"float - exclusive gt & lt - valid (above)", &cases.FloatExLTGT{Val: 11}, 0}, - {"float - exclusive gt & lt - valid (below)", &cases.FloatExLTGT{Val: -1}, 0}, - {"float - exclusive gt & lt - invalid", &cases.FloatExLTGT{Val: 5}, 1}, - {"float - exclusive gt & lt - invalid (max)", &cases.FloatExLTGT{Val: 10}, 1}, - {"float - exclusive gt & lt - invalid (min)", &cases.FloatExLTGT{Val: 0}, 1}, - {"float - gte & lte - valid", &cases.FloatGTELTE{Val: 200}, 0}, - {"float - gte & lte - valid (max)", &cases.FloatGTELTE{Val: 256}, 0}, - {"float - gte & lte - valid (min)", &cases.FloatGTELTE{Val: 128}, 0}, - {"float - gte & lte - invalid (above)", &cases.FloatGTELTE{Val: 300}, 1}, - {"float - gte & lte - invalid (below)", &cases.FloatGTELTE{Val: 100}, 1}, - {"float - exclusive gte & lte - valid (above)", &cases.FloatExGTELTE{Val: 300}, 0}, - {"float - exclusive gte & lte - valid (below)", &cases.FloatExGTELTE{Val: 100}, 0}, - {"float - exclusive gte & lte - valid (max)", &cases.FloatExGTELTE{Val: 256}, 0}, - {"float - exclusive gte & lte - valid (min)", &cases.FloatExGTELTE{Val: 128}, 0}, - {"float - exclusive gte & lte - invalid", &cases.FloatExGTELTE{Val: 200}, 1}, - {"float - ignore_empty gte & lte - valid", &cases.FloatIgnore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestDoubleCases() { - tests := []TestCase{ - {"double - none - valid", &cases.DoubleNone{Val: -1.23456}, 0}, - {"double - const - valid", &cases.DoubleConst{Val: 1.23}, 0}, - {"double - const - invalid", &cases.DoubleConst{Val: 4.56}, 1}, - {"double - in - valid", &cases.DoubleIn{Val: 7.89}, 0}, - {"double - in - invalid", &cases.DoubleIn{Val: 10.11}, 1}, - {"double - not in - valid", &cases.DoubleNotIn{Val: 1}, 0}, - {"double - not in - invalid", &cases.DoubleNotIn{Val: 0}, 1}, - {"double - lt - valid", &cases.DoubleLT{Val: -1}, 0}, - {"double - lt - invalid (equal)", &cases.DoubleLT{Val: 0}, 1}, - {"double - lt - invalid", &cases.DoubleLT{Val: 1}, 1}, - {"double - lte - valid", &cases.DoubleLTE{Val: 63}, 0}, - {"double - lte - valid (equal)", &cases.DoubleLTE{Val: 64}, 0}, - {"double - lte - invalid", &cases.DoubleLTE{Val: 65}, 1}, - {"double - gt - valid", &cases.DoubleGT{Val: 17}, 0}, - {"double - gt - invalid (equal)", &cases.DoubleGT{Val: 16}, 1}, - {"double - gt - invalid", &cases.DoubleGT{Val: 15}, 1}, - {"double - gte - valid", &cases.DoubleGTE{Val: 9}, 0}, - {"double - gte - valid (equal)", &cases.DoubleGTE{Val: 8}, 0}, - {"double - gte - invalid", &cases.DoubleGTE{Val: 7}, 1}, - {"double - gt & lt - valid", &cases.DoubleGTLT{Val: 5}, 0}, - {"double - gt & lt - invalid (above)", &cases.DoubleGTLT{Val: 11}, 1}, - {"double - gt & lt - invalid (below)", &cases.DoubleGTLT{Val: -1}, 1}, - {"double - gt & lt - invalid (max)", &cases.DoubleGTLT{Val: 10}, 1}, - {"double - gt & lt - invalid (min)", &cases.DoubleGTLT{Val: 0}, 1}, - {"double - exclusive gt & lt - valid (above)", &cases.DoubleExLTGT{Val: 11}, 0}, - {"double - exclusive gt & lt - valid (below)", &cases.DoubleExLTGT{Val: -1}, 0}, - {"double - exclusive gt & lt - invalid", &cases.DoubleExLTGT{Val: 5}, 1}, - {"double - exclusive gt & lt - invalid (max)", &cases.DoubleExLTGT{Val: 10}, 1}, - {"double - exclusive gt & lt - invalid (min)", &cases.DoubleExLTGT{Val: 0}, 1}, - {"double - gte & lte - valid", &cases.DoubleGTELTE{Val: 200}, 0}, - {"double - gte & lte - valid (max)", &cases.DoubleGTELTE{Val: 256}, 0}, - {"double - gte & lte - valid (min)", &cases.DoubleGTELTE{Val: 128}, 0}, - {"double - gte & lte - invalid (above)", &cases.DoubleGTELTE{Val: 300}, 1}, - {"double - gte & lte - invalid (below)", &cases.DoubleGTELTE{Val: 100}, 1}, - {"double - exclusive gte & lte - valid (above)", &cases.DoubleExGTELTE{Val: 300}, 0}, - {"double - exclusive gte & lte - valid (below)", &cases.DoubleExGTELTE{Val: 100}, 0}, - {"double - exclusive gte & lte - valid (max)", &cases.DoubleExGTELTE{Val: 256}, 0}, - {"double - exclusive gte & lte - valid (min)", &cases.DoubleExGTELTE{Val: 128}, 0}, - {"double - exclusive gte & lte - invalid", &cases.DoubleExGTELTE{Val: 200}, 1}, - {"double - ignore_empty gte & lte - valid", &cases.DoubleIgnore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestInt32Cases() { - tests := []TestCase{ - {"int32 - none - valid", &cases.Int32None{Val: 123}, 0}, - {"int32 - const - valid", &cases.Int32Const{Val: 1}, 0}, - {"int32 - const - invalid", &cases.Int32Const{Val: 2}, 1}, - {"int32 - in - valid", &cases.Int32In{Val: 3}, 0}, - {"int32 - in - invalid", &cases.Int32In{Val: 5}, 1}, - {"int32 - not in - valid", &cases.Int32NotIn{Val: 1}, 0}, - {"int32 - not in - invalid", &cases.Int32NotIn{Val: 0}, 1}, - {"int32 - lt - valid", &cases.Int32LT{Val: -1}, 0}, - {"int32 - lt - invalid (equal)", &cases.Int32LT{Val: 0}, 1}, - {"int32 - lt - invalid", &cases.Int32LT{Val: 1}, 1}, - {"int32 - lte - valid", &cases.Int32LTE{Val: 63}, 0}, - {"int32 - lte - valid (equal)", &cases.Int32LTE{Val: 64}, 0}, - {"int32 - lte - invalid", &cases.Int32LTE{Val: 65}, 1}, - {"int32 - gt - valid", &cases.Int32GT{Val: 17}, 0}, - {"int32 - gt - invalid (equal)", &cases.Int32GT{Val: 16}, 1}, - {"int32 - gt - invalid", &cases.Int32GT{Val: 15}, 1}, - {"int32 - gte - valid", &cases.Int32GTE{Val: 9}, 0}, - {"int32 - gte - valid (equal)", &cases.Int32GTE{Val: 8}, 0}, - {"int32 - gte - invalid", &cases.Int32GTE{Val: 7}, 1}, - {"int32 - gt & lt - valid", &cases.Int32GTLT{Val: 5}, 0}, - {"int32 - gt & lt - invalid (above)", &cases.Int32GTLT{Val: 11}, 1}, - {"int32 - gt & lt - invalid (below)", &cases.Int32GTLT{Val: -1}, 1}, - {"int32 - gt & lt - invalid (max)", &cases.Int32GTLT{Val: 10}, 1}, - {"int32 - gt & lt - invalid (min)", &cases.Int32GTLT{Val: 0}, 1}, - {"int32 - exclusive gt & lt - valid (above)", &cases.Int32ExLTGT{Val: 11}, 0}, - {"int32 - exclusive gt & lt - valid (below)", &cases.Int32ExLTGT{Val: -1}, 0}, - {"int32 - exclusive gt & lt - invalid", &cases.Int32ExLTGT{Val: 5}, 1}, - {"int32 - exclusive gt & lt - invalid (max)", &cases.Int32ExLTGT{Val: 10}, 1}, - {"int32 - exclusive gt & lt - invalid (min)", &cases.Int32ExLTGT{Val: 0}, 1}, - {"int32 - gte & lte - valid", &cases.Int32GTELTE{Val: 200}, 0}, - {"int32 - gte & lte - valid (max)", &cases.Int32GTELTE{Val: 256}, 0}, - {"int32 - gte & lte - valid (min)", &cases.Int32GTELTE{Val: 128}, 0}, - {"int32 - gte & lte - invalid (above)", &cases.Int32GTELTE{Val: 300}, 1}, - {"int32 - gte & lte - invalid (below)", &cases.Int32GTELTE{Val: 100}, 1}, - {"int32 - exclusive gte & lte - valid (above)", &cases.Int32ExGTELTE{Val: 300}, 0}, - {"int32 - exclusive gte & lte - valid (below)", &cases.Int32ExGTELTE{Val: 100}, 0}, - {"int32 - exclusive gte & lte - valid (max)", &cases.Int32ExGTELTE{Val: 256}, 0}, - {"int32 - exclusive gte & lte - valid (min)", &cases.Int32ExGTELTE{Val: 128}, 0}, - {"int32 - exclusive gte & lte - invalid", &cases.Int32ExGTELTE{Val: 200}, 1}, - {"int32 - ignore_empty gte & lte - valid", &cases.Int32Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestInt64Cases() { - tests := []TestCase{ - {"int64 - none - valid", &cases.Int64None{Val: 123}, 0}, - {"int64 - const - valid", &cases.Int64Const{Val: 1}, 0}, - {"int64 - const - invalid", &cases.Int64Const{Val: 2}, 1}, - {"int64 - in - valid", &cases.Int64In{Val: 3}, 0}, - {"int64 - in - invalid", &cases.Int64In{Val: 5}, 1}, - {"int64 - not in - valid", &cases.Int64NotIn{Val: 1}, 0}, - {"int64 - not in - invalid", &cases.Int64NotIn{Val: 0}, 1}, - {"int64 - lt - valid", &cases.Int64LT{Val: -1}, 0}, - {"int64 - lt - invalid (equal)", &cases.Int64LT{Val: 0}, 1}, - {"int64 - lt - invalid", &cases.Int64LT{Val: 1}, 1}, - {"int64 - lte - valid", &cases.Int64LTE{Val: 63}, 0}, - {"int64 - lte - valid (equal)", &cases.Int64LTE{Val: 64}, 0}, - {"int64 - lte - invalid", &cases.Int64LTE{Val: 65}, 1}, - {"int64 - gt - valid", &cases.Int64GT{Val: 17}, 0}, - {"int64 - gt - invalid (equal)", &cases.Int64GT{Val: 16}, 1}, - {"int64 - gt - invalid", &cases.Int64GT{Val: 15}, 1}, - {"int64 - gte - valid", &cases.Int64GTE{Val: 9}, 0}, - {"int64 - gte - valid (equal)", &cases.Int64GTE{Val: 8}, 0}, - {"int64 - gte - invalid", &cases.Int64GTE{Val: 7}, 1}, - {"int64 - gt & lt - valid", &cases.Int64GTLT{Val: 5}, 0}, - {"int64 - gt & lt - invalid (above)", &cases.Int64GTLT{Val: 11}, 1}, - {"int64 - gt & lt - invalid (below)", &cases.Int64GTLT{Val: -1}, 1}, - {"int64 - gt & lt - invalid (max)", &cases.Int64GTLT{Val: 10}, 1}, - {"int64 - gt & lt - invalid (min)", &cases.Int64GTLT{Val: 0}, 1}, - {"int64 - exclusive gt & lt - valid (above)", &cases.Int64ExLTGT{Val: 11}, 0}, - {"int64 - exclusive gt & lt - valid (below)", &cases.Int64ExLTGT{Val: -1}, 0}, - {"int64 - exclusive gt & lt - invalid", &cases.Int64ExLTGT{Val: 5}, 1}, - {"int64 - exclusive gt & lt - invalid (max)", &cases.Int64ExLTGT{Val: 10}, 1}, - {"int64 - exclusive gt & lt - invalid (min)", &cases.Int64ExLTGT{Val: 0}, 1}, - {"int64 - gte & lte - valid", &cases.Int64GTELTE{Val: 200}, 0}, - {"int64 - gte & lte - valid (max)", &cases.Int64GTELTE{Val: 256}, 0}, - {"int64 - gte & lte - valid (min)", &cases.Int64GTELTE{Val: 128}, 0}, - {"int64 - gte & lte - invalid (above)", &cases.Int64GTELTE{Val: 300}, 1}, - {"int64 - gte & lte - invalid (below)", &cases.Int64GTELTE{Val: 100}, 1}, - {"int64 - exclusive gte & lte - valid (above)", &cases.Int64ExGTELTE{Val: 300}, 0}, - {"int64 - exclusive gte & lte - valid (below)", &cases.Int64ExGTELTE{Val: 100}, 0}, - {"int64 - exclusive gte & lte - valid (max)", &cases.Int64ExGTELTE{Val: 256}, 0}, - {"int64 - exclusive gte & lte - valid (min)", &cases.Int64ExGTELTE{Val: 128}, 0}, - {"int64 - exclusive gte & lte - invalid", &cases.Int64ExGTELTE{Val: 200}, 1}, - {"int64 - ignore_empty gte & lte - valid", &cases.Int64Ignore{Val: 0}, 0}, - {"int64 optional - lte - valid", &cases.Int64LTEOptional{Val: &wrapperspb.Int64(63).Value}, 0}, - {"int64 optional - lte - valid (equal)", &cases.Int64LTEOptional{Val: &wrapperspb.Int64(64).Value}, 0}, - {"int64 optional - lte - valid (unset)", &cases.Int64LTEOptional{}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestUint32Cases() { - tests := []TestCase{ - {"uint32 - none - valid", &cases.UInt32None{Val: 123}, 0}, - {"uint32 - const - valid", &cases.UInt32Const{Val: 1}, 0}, - {"uint32 - const - invalid", &cases.UInt32Const{Val: 2}, 1}, - {"uint32 - in - valid", &cases.UInt32In{Val: 3}, 0}, - {"uint32 - in - invalid", &cases.UInt32In{Val: 5}, 1}, - {"uint32 - not in - valid", &cases.UInt32NotIn{Val: 1}, 0}, - {"uint32 - not in - invalid", &cases.UInt32NotIn{Val: 0}, 1}, - {"uint32 - lt - valid", &cases.UInt32LT{Val: 4}, 0}, - {"uint32 - lt - invalid (equal)", &cases.UInt32LT{Val: 5}, 1}, - {"uint32 - lt - invalid", &cases.UInt32LT{Val: 6}, 1}, - {"uint32 - lte - valid", &cases.UInt32LTE{Val: 63}, 0}, - {"uint32 - lte - valid (equal)", &cases.UInt32LTE{Val: 64}, 0}, - {"uint32 - lte - invalid", &cases.UInt32LTE{Val: 65}, 1}, - {"uint32 - gt - valid", &cases.UInt32GT{Val: 17}, 0}, - {"uint32 - gt - invalid (equal)", &cases.UInt32GT{Val: 16}, 1}, - {"uint32 - gt - invalid", &cases.UInt32GT{Val: 15}, 1}, - {"uint32 - gte - valid", &cases.UInt32GTE{Val: 9}, 0}, - {"uint32 - gte - valid (equal)", &cases.UInt32GTE{Val: 8}, 0}, - {"uint32 - gte - invalid", &cases.UInt32GTE{Val: 7}, 1}, - {"uint32 - gt & lt - valid", &cases.UInt32GTLT{Val: 7}, 0}, - {"uint32 - gt & lt - invalid (above)", &cases.UInt32GTLT{Val: 11}, 1}, - {"uint32 - gt & lt - invalid (below)", &cases.UInt32GTLT{Val: 1}, 1}, - {"uint32 - gt & lt - invalid (max)", &cases.UInt32GTLT{Val: 10}, 1}, - {"uint32 - gt & lt - invalid (min)", &cases.UInt32GTLT{Val: 5}, 1}, - {"uint32 - exclusive gt & lt - valid (above)", &cases.UInt32ExLTGT{Val: 11}, 0}, - {"uint32 - exclusive gt & lt - valid (below)", &cases.UInt32ExLTGT{Val: 4}, 0}, - {"uint32 - exclusive gt & lt - invalid", &cases.UInt32ExLTGT{Val: 7}, 1}, - {"uint32 - exclusive gt & lt - invalid (max)", &cases.UInt32ExLTGT{Val: 10}, 1}, - {"uint32 - exclusive gt & lt - invalid (min)", &cases.UInt32ExLTGT{Val: 5}, 1}, - {"uint32 - gte & lte - valid", &cases.UInt32GTELTE{Val: 200}, 0}, - {"uint32 - gte & lte - valid (max)", &cases.UInt32GTELTE{Val: 256}, 0}, - {"uint32 - gte & lte - valid (min)", &cases.UInt32GTELTE{Val: 128}, 0}, - {"uint32 - gte & lte - invalid (above)", &cases.UInt32GTELTE{Val: 300}, 1}, - {"uint32 - gte & lte - invalid (below)", &cases.UInt32GTELTE{Val: 100}, 1}, - {"uint32 - exclusive gte & lte - valid (above)", &cases.UInt32ExGTELTE{Val: 300}, 0}, - {"uint32 - exclusive gte & lte - valid (below)", &cases.UInt32ExGTELTE{Val: 100}, 0}, - {"uint32 - exclusive gte & lte - valid (max)", &cases.UInt32ExGTELTE{Val: 256}, 0}, - {"uint32 - exclusive gte & lte - valid (min)", &cases.UInt32ExGTELTE{Val: 128}, 0}, - {"uint32 - exclusive gte & lte - invalid", &cases.UInt32ExGTELTE{Val: 200}, 1}, - {"uint32 - ignore_empty gte & lte - valid", &cases.UInt32Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestUint64Cases() { - tests := []TestCase{ - {"uint64 - none - valid", &cases.UInt64None{Val: 123}, 0}, - {"uint64 - const - valid", &cases.UInt64Const{Val: 1}, 0}, - {"uint64 - const - invalid", &cases.UInt64Const{Val: 2}, 1}, - {"uint64 - in - valid", &cases.UInt64In{Val: 3}, 0}, - {"uint64 - in - invalid", &cases.UInt64In{Val: 5}, 1}, - {"uint64 - not in - valid", &cases.UInt64NotIn{Val: 1}, 0}, - {"uint64 - not in - invalid", &cases.UInt64NotIn{Val: 0}, 1}, - {"uint64 - lt - valid", &cases.UInt64LT{Val: 4}, 0}, - {"uint64 - lt - invalid (equal)", &cases.UInt64LT{Val: 5}, 1}, - {"uint64 - lt - invalid", &cases.UInt64LT{Val: 6}, 1}, - {"uint64 - lte - valid", &cases.UInt64LTE{Val: 63}, 0}, - {"uint64 - lte - valid (equal)", &cases.UInt64LTE{Val: 64}, 0}, - {"uint64 - lte - invalid", &cases.UInt64LTE{Val: 65}, 1}, - {"uint64 - gt - valid", &cases.UInt64GT{Val: 17}, 0}, - {"uint64 - gt - invalid (equal)", &cases.UInt64GT{Val: 16}, 1}, - {"uint64 - gt - invalid", &cases.UInt64GT{Val: 15}, 1}, - {"uint64 - gte - valid", &cases.UInt64GTE{Val: 9}, 0}, - {"uint64 - gte - valid (equal)", &cases.UInt64GTE{Val: 8}, 0}, - {"uint64 - gte - invalid", &cases.UInt64GTE{Val: 7}, 1}, - {"uint64 - gt & lt - valid", &cases.UInt64GTLT{Val: 7}, 0}, - {"uint64 - gt & lt - invalid (above)", &cases.UInt64GTLT{Val: 11}, 1}, - {"uint64 - gt & lt - invalid (below)", &cases.UInt64GTLT{Val: 1}, 1}, - {"uint64 - gt & lt - invalid (max)", &cases.UInt64GTLT{Val: 10}, 1}, - {"uint64 - gt & lt - invalid (min)", &cases.UInt64GTLT{Val: 5}, 1}, - {"uint64 - exclusive gt & lt - valid (above)", &cases.UInt64ExLTGT{Val: 11}, 0}, - {"uint64 - exclusive gt & lt - valid (below)", &cases.UInt64ExLTGT{Val: 4}, 0}, - {"uint64 - exclusive gt & lt - invalid", &cases.UInt64ExLTGT{Val: 7}, 1}, - {"uint64 - exclusive gt & lt - invalid (max)", &cases.UInt64ExLTGT{Val: 10}, 1}, - {"uint64 - exclusive gt & lt - invalid (min)", &cases.UInt64ExLTGT{Val: 5}, 1}, - {"uint64 - gte & lte - valid", &cases.UInt64GTELTE{Val: 200}, 0}, - {"uint64 - gte & lte - valid (max)", &cases.UInt64GTELTE{Val: 256}, 0}, - {"uint64 - gte & lte - valid (min)", &cases.UInt64GTELTE{Val: 128}, 0}, - {"uint64 - gte & lte - invalid (above)", &cases.UInt64GTELTE{Val: 300}, 1}, - {"uint64 - gte & lte - invalid (below)", &cases.UInt64GTELTE{Val: 100}, 1}, - {"uint64 - exclusive gte & lte - valid (above)", &cases.UInt64ExGTELTE{Val: 300}, 0}, - {"uint64 - exclusive gte & lte - valid (below)", &cases.UInt64ExGTELTE{Val: 100}, 0}, - {"uint64 - exclusive gte & lte - valid (max)", &cases.UInt64ExGTELTE{Val: 256}, 0}, - {"uint64 - exclusive gte & lte - valid (min)", &cases.UInt64ExGTELTE{Val: 128}, 0}, - {"uint64 - exclusive gte & lte - invalid", &cases.UInt64ExGTELTE{Val: 200}, 1}, - {"uint64 - ignore_empty gte & lte - valid", &cases.UInt64Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestSint32Cases() { - tests := []TestCase{ - {"sint32 - none - valid", &cases.SInt32None{Val: 123}, 0}, - {"sint32 - const - valid", &cases.SInt32Const{Val: 1}, 0}, - {"sint32 - const - invalid", &cases.SInt32Const{Val: 2}, 1}, - {"sint32 - in - valid", &cases.SInt32In{Val: 3}, 0}, - {"sint32 - in - invalid", &cases.SInt32In{Val: 5}, 1}, - {"sint32 - not in - valid", &cases.SInt32NotIn{Val: 1}, 0}, - {"sint32 - not in - invalid", &cases.SInt32NotIn{Val: 0}, 1}, - {"sint32 - lt - valid", &cases.SInt32LT{Val: -1}, 0}, - {"sint32 - lt - invalid (equal)", &cases.SInt32LT{Val: 0}, 1}, - {"sint32 - lt - invalid", &cases.SInt32LT{Val: 1}, 1}, - {"sint32 - lte - valid", &cases.SInt32LTE{Val: 63}, 0}, - {"sint32 - lte - valid (equal)", &cases.SInt32LTE{Val: 64}, 0}, - {"sint32 - lte - invalid", &cases.SInt32LTE{Val: 65}, 1}, - {"sint32 - gt - valid", &cases.SInt32GT{Val: 17}, 0}, - {"sint32 - gt - invalid (equal)", &cases.SInt32GT{Val: 16}, 1}, - {"sint32 - gt - invalid", &cases.SInt32GT{Val: 15}, 1}, - {"sint32 - gte - valid", &cases.SInt32GTE{Val: 9}, 0}, - {"sint32 - gte - valid (equal)", &cases.SInt32GTE{Val: 8}, 0}, - {"sint32 - gte - invalid", &cases.SInt32GTE{Val: 7}, 1}, - {"sint32 - gt & lt - valid", &cases.SInt32GTLT{Val: 5}, 0}, - {"sint32 - gt & lt - invalid (above)", &cases.SInt32GTLT{Val: 11}, 1}, - {"sint32 - gt & lt - invalid (below)", &cases.SInt32GTLT{Val: -1}, 1}, - {"sint32 - gt & lt - invalid (max)", &cases.SInt32GTLT{Val: 10}, 1}, - {"sint32 - gt & lt - invalid (min)", &cases.SInt32GTLT{Val: 0}, 1}, - {"sint32 - exclusive gt & lt - valid (above)", &cases.SInt32ExLTGT{Val: 11}, 0}, - {"sint32 - exclusive gt & lt - valid (below)", &cases.SInt32ExLTGT{Val: -1}, 0}, - {"sint32 - exclusive gt & lt - invalid", &cases.SInt32ExLTGT{Val: 5}, 1}, - {"sint32 - exclusive gt & lt - invalid (max)", &cases.SInt32ExLTGT{Val: 10}, 1}, - {"sint32 - exclusive gt & lt - invalid (min)", &cases.SInt32ExLTGT{Val: 0}, 1}, - {"sint32 - gte & lte - valid", &cases.SInt32GTELTE{Val: 200}, 0}, - {"sint32 - gte & lte - valid (max)", &cases.SInt32GTELTE{Val: 256}, 0}, - {"sint32 - gte & lte - valid (min)", &cases.SInt32GTELTE{Val: 128}, 0}, - {"sint32 - gte & lte - invalid (above)", &cases.SInt32GTELTE{Val: 300}, 1}, - {"sint32 - gte & lte - invalid (below)", &cases.SInt32GTELTE{Val: 100}, 1}, - {"sint32 - exclusive gte & lte - valid (above)", &cases.SInt32ExGTELTE{Val: 300}, 0}, - {"sint32 - exclusive gte & lte - valid (below)", &cases.SInt32ExGTELTE{Val: 100}, 0}, - {"sint32 - exclusive gte & lte - valid (max)", &cases.SInt32ExGTELTE{Val: 256}, 0}, - {"sint32 - exclusive gte & lte - valid (min)", &cases.SInt32ExGTELTE{Val: 128}, 0}, - {"sint32 - exclusive gte & lte - invalid", &cases.SInt32ExGTELTE{Val: 200}, 1}, - {"sint32 - ignore_empty gte & lte - valid", &cases.SInt32Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestSint64Cases() { - tests := []TestCase{ - {"sint64 - none - valid", &cases.SInt64None{Val: 123}, 0}, - {"sint64 - const - valid", &cases.SInt64Const{Val: 1}, 0}, - {"sint64 - const - invalid", &cases.SInt64Const{Val: 2}, 1}, - {"sint64 - in - valid", &cases.SInt64In{Val: 3}, 0}, - {"sint64 - in - invalid", &cases.SInt64In{Val: 5}, 1}, - {"sint64 - not in - valid", &cases.SInt64NotIn{Val: 1}, 0}, - {"sint64 - not in - invalid", &cases.SInt64NotIn{Val: 0}, 1}, - {"sint64 - lt - valid", &cases.SInt64LT{Val: -1}, 0}, - {"sint64 - lt - invalid (equal)", &cases.SInt64LT{Val: 0}, 1}, - {"sint64 - lt - invalid", &cases.SInt64LT{Val: 1}, 1}, - {"sint64 - lte - valid", &cases.SInt64LTE{Val: 63}, 0}, - {"sint64 - lte - valid (equal)", &cases.SInt64LTE{Val: 64}, 0}, - {"sint64 - lte - invalid", &cases.SInt64LTE{Val: 65}, 1}, - {"sint64 - gt - valid", &cases.SInt64GT{Val: 17}, 0}, - {"sint64 - gt - invalid (equal)", &cases.SInt64GT{Val: 16}, 1}, - {"sint64 - gt - invalid", &cases.SInt64GT{Val: 15}, 1}, - {"sint64 - gte - valid", &cases.SInt64GTE{Val: 9}, 0}, - {"sint64 - gte - valid (equal)", &cases.SInt64GTE{Val: 8}, 0}, - {"sint64 - gte - invalid", &cases.SInt64GTE{Val: 7}, 1}, - {"sint64 - gt & lt - valid", &cases.SInt64GTLT{Val: 5}, 0}, - {"sint64 - gt & lt - invalid (above)", &cases.SInt64GTLT{Val: 11}, 1}, - {"sint64 - gt & lt - invalid (below)", &cases.SInt64GTLT{Val: -1}, 1}, - {"sint64 - gt & lt - invalid (max)", &cases.SInt64GTLT{Val: 10}, 1}, - {"sint64 - gt & lt - invalid (min)", &cases.SInt64GTLT{Val: 0}, 1}, - {"sint64 - exclusive gt & lt - valid (above)", &cases.SInt64ExLTGT{Val: 11}, 0}, - {"sint64 - exclusive gt & lt - valid (below)", &cases.SInt64ExLTGT{Val: -1}, 0}, - {"sint64 - exclusive gt & lt - invalid", &cases.SInt64ExLTGT{Val: 5}, 1}, - {"sint64 - exclusive gt & lt - invalid (max)", &cases.SInt64ExLTGT{Val: 10}, 1}, - {"sint64 - exclusive gt & lt - invalid (min)", &cases.SInt64ExLTGT{Val: 0}, 1}, - {"sint64 - gte & lte - valid", &cases.SInt64GTELTE{Val: 200}, 0}, - {"sint64 - gte & lte - valid (max)", &cases.SInt64GTELTE{Val: 256}, 0}, - {"sint64 - gte & lte - valid (min)", &cases.SInt64GTELTE{Val: 128}, 0}, - {"sint64 - gte & lte - invalid (above)", &cases.SInt64GTELTE{Val: 300}, 1}, - {"sint64 - gte & lte - invalid (below)", &cases.SInt64GTELTE{Val: 100}, 1}, - {"sint64 - exclusive gte & lte - valid (above)", &cases.SInt64ExGTELTE{Val: 300}, 0}, - {"sint64 - exclusive gte & lte - valid (below)", &cases.SInt64ExGTELTE{Val: 100}, 0}, - {"sint64 - exclusive gte & lte - valid (max)", &cases.SInt64ExGTELTE{Val: 256}, 0}, - {"sint64 - exclusive gte & lte - valid (min)", &cases.SInt64ExGTELTE{Val: 128}, 0}, - {"sint64 - exclusive gte & lte - invalid", &cases.SInt64ExGTELTE{Val: 200}, 1}, - {"sint64 - ignore_empty gte & lte - valid", &cases.SInt64Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestFixed32Cases() { - tests := []TestCase{ - {"fixed32 - none - valid", &cases.Fixed32None{Val: 123}, 0}, - {"fixed32 - const - valid", &cases.Fixed32Const{Val: 1}, 0}, - {"fixed32 - const - invalid", &cases.Fixed32Const{Val: 2}, 1}, - {"fixed32 - in - valid", &cases.Fixed32In{Val: 3}, 0}, - {"fixed32 - in - invalid", &cases.Fixed32In{Val: 5}, 1}, - {"fixed32 - not in - valid", &cases.Fixed32NotIn{Val: 1}, 0}, - {"fixed32 - not in - invalid", &cases.Fixed32NotIn{Val: 0}, 1}, - {"fixed32 - lt - valid", &cases.Fixed32LT{Val: 4}, 0}, - {"fixed32 - lt - invalid (equal)", &cases.Fixed32LT{Val: 5}, 1}, - {"fixed32 - lt - invalid", &cases.Fixed32LT{Val: 6}, 1}, - {"fixed32 - lte - valid", &cases.Fixed32LTE{Val: 63}, 0}, - {"fixed32 - lte - valid (equal)", &cases.Fixed32LTE{Val: 64}, 0}, - {"fixed32 - lte - invalid", &cases.Fixed32LTE{Val: 65}, 1}, - {"fixed32 - gt - valid", &cases.Fixed32GT{Val: 17}, 0}, - {"fixed32 - gt - invalid (equal)", &cases.Fixed32GT{Val: 16}, 1}, - {"fixed32 - gt - invalid", &cases.Fixed32GT{Val: 15}, 1}, - {"fixed32 - gte - valid", &cases.Fixed32GTE{Val: 9}, 0}, - {"fixed32 - gte - valid (equal)", &cases.Fixed32GTE{Val: 8}, 0}, - {"fixed32 - gte - invalid", &cases.Fixed32GTE{Val: 7}, 1}, - {"fixed32 - gt & lt - valid", &cases.Fixed32GTLT{Val: 7}, 0}, - {"fixed32 - gt & lt - invalid (above)", &cases.Fixed32GTLT{Val: 11}, 1}, - {"fixed32 - gt & lt - invalid (below)", &cases.Fixed32GTLT{Val: 1}, 1}, - {"fixed32 - gt & lt - invalid (max)", &cases.Fixed32GTLT{Val: 10}, 1}, - {"fixed32 - gt & lt - invalid (min)", &cases.Fixed32GTLT{Val: 5}, 1}, - {"fixed32 - exclusive gt & lt - valid (above)", &cases.Fixed32ExLTGT{Val: 11}, 0}, - {"fixed32 - exclusive gt & lt - valid (below)", &cases.Fixed32ExLTGT{Val: 4}, 0}, - {"fixed32 - exclusive gt & lt - invalid", &cases.Fixed32ExLTGT{Val: 7}, 1}, - {"fixed32 - exclusive gt & lt - invalid (max)", &cases.Fixed32ExLTGT{Val: 10}, 1}, - {"fixed32 - exclusive gt & lt - invalid (min)", &cases.Fixed32ExLTGT{Val: 5}, 1}, - {"fixed32 - gte & lte - valid", &cases.Fixed32GTELTE{Val: 200}, 0}, - {"fixed32 - gte & lte - valid (max)", &cases.Fixed32GTELTE{Val: 256}, 0}, - {"fixed32 - gte & lte - valid (min)", &cases.Fixed32GTELTE{Val: 128}, 0}, - {"fixed32 - gte & lte - invalid (above)", &cases.Fixed32GTELTE{Val: 300}, 1}, - {"fixed32 - gte & lte - invalid (below)", &cases.Fixed32GTELTE{Val: 100}, 1}, - {"fixed32 - exclusive gte & lte - valid (above)", &cases.Fixed32ExGTELTE{Val: 300}, 0}, - {"fixed32 - exclusive gte & lte - valid (below)", &cases.Fixed32ExGTELTE{Val: 100}, 0}, - {"fixed32 - exclusive gte & lte - valid (max)", &cases.Fixed32ExGTELTE{Val: 256}, 0}, - {"fixed32 - exclusive gte & lte - valid (min)", &cases.Fixed32ExGTELTE{Val: 128}, 0}, - {"fixed32 - exclusive gte & lte - invalid", &cases.Fixed32ExGTELTE{Val: 200}, 1}, - {"fixed32 - ignore_empty gte & lte - valid", &cases.Fixed32Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestFixed64Cases() { - tests := []TestCase{ - {"fixed64 - none - valid", &cases.Fixed64None{Val: 123}, 0}, - {"fixed64 - const - valid", &cases.Fixed64Const{Val: 1}, 0}, - {"fixed64 - const - invalid", &cases.Fixed64Const{Val: 2}, 1}, - {"fixed64 - in - valid", &cases.Fixed64In{Val: 3}, 0}, - {"fixed64 - in - invalid", &cases.Fixed64In{Val: 5}, 1}, - {"fixed64 - not in - valid", &cases.Fixed64NotIn{Val: 1}, 0}, - {"fixed64 - not in - invalid", &cases.Fixed64NotIn{Val: 0}, 1}, - {"fixed64 - lt - valid", &cases.Fixed64LT{Val: 4}, 0}, - {"fixed64 - lt - invalid (equal)", &cases.Fixed64LT{Val: 5}, 1}, - {"fixed64 - lt - invalid", &cases.Fixed64LT{Val: 6}, 1}, - {"fixed64 - lte - valid", &cases.Fixed64LTE{Val: 63}, 0}, - {"fixed64 - lte - valid (equal)", &cases.Fixed64LTE{Val: 64}, 0}, - {"fixed64 - lte - invalid", &cases.Fixed64LTE{Val: 65}, 1}, - {"fixed64 - gt - valid", &cases.Fixed64GT{Val: 17}, 0}, - {"fixed64 - gt - invalid (equal)", &cases.Fixed64GT{Val: 16}, 1}, - {"fixed64 - gt - invalid", &cases.Fixed64GT{Val: 15}, 1}, - {"fixed64 - gte - valid", &cases.Fixed64GTE{Val: 9}, 0}, - {"fixed64 - gte - valid (equal)", &cases.Fixed64GTE{Val: 8}, 0}, - {"fixed64 - gte - invalid", &cases.Fixed64GTE{Val: 7}, 1}, - {"fixed64 - gt & lt - valid", &cases.Fixed64GTLT{Val: 7}, 0}, - {"fixed64 - gt & lt - invalid (above)", &cases.Fixed64GTLT{Val: 11}, 1}, - {"fixed64 - gt & lt - invalid (below)", &cases.Fixed64GTLT{Val: 1}, 1}, - {"fixed64 - gt & lt - invalid (max)", &cases.Fixed64GTLT{Val: 10}, 1}, - {"fixed64 - gt & lt - invalid (min)", &cases.Fixed64GTLT{Val: 5}, 1}, - {"fixed64 - exclusive gt & lt - valid (above)", &cases.Fixed64ExLTGT{Val: 11}, 0}, - {"fixed64 - exclusive gt & lt - valid (below)", &cases.Fixed64ExLTGT{Val: 4}, 0}, - {"fixed64 - exclusive gt & lt - invalid", &cases.Fixed64ExLTGT{Val: 7}, 1}, - {"fixed64 - exclusive gt & lt - invalid (max)", &cases.Fixed64ExLTGT{Val: 10}, 1}, - {"fixed64 - exclusive gt & lt - invalid (min)", &cases.Fixed64ExLTGT{Val: 5}, 1}, - {"fixed64 - gte & lte - valid", &cases.Fixed64GTELTE{Val: 200}, 0}, - {"fixed64 - gte & lte - valid (max)", &cases.Fixed64GTELTE{Val: 256}, 0}, - {"fixed64 - gte & lte - valid (min)", &cases.Fixed64GTELTE{Val: 128}, 0}, - {"fixed64 - gte & lte - invalid (above)", &cases.Fixed64GTELTE{Val: 300}, 1}, - {"fixed64 - gte & lte - invalid (below)", &cases.Fixed64GTELTE{Val: 100}, 1}, - {"fixed64 - exclusive gte & lte - valid (above)", &cases.Fixed64ExGTELTE{Val: 300}, 0}, - {"fixed64 - exclusive gte & lte - valid (below)", &cases.Fixed64ExGTELTE{Val: 100}, 0}, - {"fixed64 - exclusive gte & lte - valid (max)", &cases.Fixed64ExGTELTE{Val: 256}, 0}, - {"fixed64 - exclusive gte & lte - valid (min)", &cases.Fixed64ExGTELTE{Val: 128}, 0}, - {"fixed64 - exclusive gte & lte - invalid", &cases.Fixed64ExGTELTE{Val: 200}, 1}, - {"fixed64 - ignore_empty gte & lte - valid", &cases.Fixed64Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestSfixed32Cases() { - tests := []TestCase{ - {"sfixed32 - none - valid", &cases.SFixed32None{Val: 123}, 0}, - {"sfixed32 - const - valid", &cases.SFixed32Const{Val: 1}, 0}, - {"sfixed32 - const - invalid", &cases.SFixed32Const{Val: 2}, 1}, - {"sfixed32 - in - valid", &cases.SFixed32In{Val: 3}, 0}, - {"sfixed32 - in - invalid", &cases.SFixed32In{Val: 5}, 1}, - {"sfixed32 - not in - valid", &cases.SFixed32NotIn{Val: 1}, 0}, - {"sfixed32 - not in - invalid", &cases.SFixed32NotIn{Val: 0}, 1}, - {"sfixed32 - lt - valid", &cases.SFixed32LT{Val: -1}, 0}, - {"sfixed32 - lt - invalid (equal)", &cases.SFixed32LT{Val: 0}, 1}, - {"sfixed32 - lt - invalid", &cases.SFixed32LT{Val: 1}, 1}, - {"sfixed32 - lte - valid", &cases.SFixed32LTE{Val: 63}, 0}, - {"sfixed32 - lte - valid (equal)", &cases.SFixed32LTE{Val: 64}, 0}, - {"sfixed32 - lte - invalid", &cases.SFixed32LTE{Val: 65}, 1}, - {"sfixed32 - gt - valid", &cases.SFixed32GT{Val: 17}, 0}, - {"sfixed32 - gt - invalid (equal)", &cases.SFixed32GT{Val: 16}, 1}, - {"sfixed32 - gt - invalid", &cases.SFixed32GT{Val: 15}, 1}, - {"sfixed32 - gte - valid", &cases.SFixed32GTE{Val: 9}, 0}, - {"sfixed32 - gte - valid (equal)", &cases.SFixed32GTE{Val: 8}, 0}, - {"sfixed32 - gte - invalid", &cases.SFixed32GTE{Val: 7}, 1}, - {"sfixed32 - gt & lt - valid", &cases.SFixed32GTLT{Val: 5}, 0}, - {"sfixed32 - gt & lt - invalid (above)", &cases.SFixed32GTLT{Val: 11}, 1}, - {"sfixed32 - gt & lt - invalid (below)", &cases.SFixed32GTLT{Val: -1}, 1}, - {"sfixed32 - gt & lt - invalid (max)", &cases.SFixed32GTLT{Val: 10}, 1}, - {"sfixed32 - gt & lt - invalid (min)", &cases.SFixed32GTLT{Val: 0}, 1}, - {"sfixed32 - exclusive gt & lt - valid (above)", &cases.SFixed32ExLTGT{Val: 11}, 0}, - {"sfixed32 - exclusive gt & lt - valid (below)", &cases.SFixed32ExLTGT{Val: -1}, 0}, - {"sfixed32 - exclusive gt & lt - invalid", &cases.SFixed32ExLTGT{Val: 5}, 1}, - {"sfixed32 - exclusive gt & lt - invalid (max)", &cases.SFixed32ExLTGT{Val: 10}, 1}, - {"sfixed32 - exclusive gt & lt - invalid (min)", &cases.SFixed32ExLTGT{Val: 0}, 1}, - {"sfixed32 - gte & lte - valid", &cases.SFixed32GTELTE{Val: 200}, 0}, - {"sfixed32 - gte & lte - valid (max)", &cases.SFixed32GTELTE{Val: 256}, 0}, - {"sfixed32 - gte & lte - valid (min)", &cases.SFixed32GTELTE{Val: 128}, 0}, - {"sfixed32 - gte & lte - invalid (above)", &cases.SFixed32GTELTE{Val: 300}, 1}, - {"sfixed32 - gte & lte - invalid (below)", &cases.SFixed32GTELTE{Val: 100}, 1}, - {"sfixed32 - exclusive gte & lte - valid (above)", &cases.SFixed32ExGTELTE{Val: 300}, 0}, - {"sfixed32 - exclusive gte & lte - valid (below)", &cases.SFixed32ExGTELTE{Val: 100}, 0}, - {"sfixed32 - exclusive gte & lte - valid (max)", &cases.SFixed32ExGTELTE{Val: 256}, 0}, - {"sfixed32 - exclusive gte & lte - valid (min)", &cases.SFixed32ExGTELTE{Val: 128}, 0}, - {"sfixed32 - exclusive gte & lte - invalid", &cases.SFixed32ExGTELTE{Val: 200}, 1}, - {"sfixed32 - ignore_empty gte & lte - valid", &cases.SFixed32Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestSfixed64Cases() { - tests := []TestCase{ - {"sfixed64 - none - valid", &cases.SFixed64None{Val: 123}, 0}, - {"sfixed64 - const - valid", &cases.SFixed64Const{Val: 1}, 0}, - {"sfixed64 - const - invalid", &cases.SFixed64Const{Val: 2}, 1}, - {"sfixed64 - in - valid", &cases.SFixed64In{Val: 3}, 0}, - {"sfixed64 - in - invalid", &cases.SFixed64In{Val: 5}, 1}, - {"sfixed64 - not in - valid", &cases.SFixed64NotIn{Val: 1}, 0}, - {"sfixed64 - not in - invalid", &cases.SFixed64NotIn{Val: 0}, 1}, - {"sfixed64 - lt - valid", &cases.SFixed64LT{Val: -1}, 0}, - {"sfixed64 - lt - invalid (equal)", &cases.SFixed64LT{Val: 0}, 1}, - {"sfixed64 - lt - invalid", &cases.SFixed64LT{Val: 1}, 1}, - {"sfixed64 - lte - valid", &cases.SFixed64LTE{Val: 63}, 0}, - {"sfixed64 - lte - valid (equal)", &cases.SFixed64LTE{Val: 64}, 0}, - {"sfixed64 - lte - invalid", &cases.SFixed64LTE{Val: 65}, 1}, - {"sfixed64 - gt - valid", &cases.SFixed64GT{Val: 17}, 0}, - {"sfixed64 - gt - invalid (equal)", &cases.SFixed64GT{Val: 16}, 1}, - {"sfixed64 - gt - invalid", &cases.SFixed64GT{Val: 15}, 1}, - {"sfixed64 - gte - valid", &cases.SFixed64GTE{Val: 9}, 0}, - {"sfixed64 - gte - valid (equal)", &cases.SFixed64GTE{Val: 8}, 0}, - {"sfixed64 - gte - invalid", &cases.SFixed64GTE{Val: 7}, 1}, - {"sfixed64 - gt & lt - valid", &cases.SFixed64GTLT{Val: 5}, 0}, - {"sfixed64 - gt & lt - invalid (above)", &cases.SFixed64GTLT{Val: 11}, 1}, - {"sfixed64 - gt & lt - invalid (below)", &cases.SFixed64GTLT{Val: -1}, 1}, - {"sfixed64 - gt & lt - invalid (max)", &cases.SFixed64GTLT{Val: 10}, 1}, - {"sfixed64 - gt & lt - invalid (min)", &cases.SFixed64GTLT{Val: 0}, 1}, - {"sfixed64 - exclusive gt & lt - valid (above)", &cases.SFixed64ExLTGT{Val: 11}, 0}, - {"sfixed64 - exclusive gt & lt - valid (below)", &cases.SFixed64ExLTGT{Val: -1}, 0}, - {"sfixed64 - exclusive gt & lt - invalid", &cases.SFixed64ExLTGT{Val: 5}, 1}, - {"sfixed64 - exclusive gt & lt - invalid (max)", &cases.SFixed64ExLTGT{Val: 10}, 1}, - {"sfixed64 - exclusive gt & lt - invalid (min)", &cases.SFixed64ExLTGT{Val: 0}, 1}, - {"sfixed64 - gte & lte - valid", &cases.SFixed64GTELTE{Val: 200}, 0}, - {"sfixed64 - gte & lte - valid (max)", &cases.SFixed64GTELTE{Val: 256}, 0}, - {"sfixed64 - gte & lte - valid (min)", &cases.SFixed64GTELTE{Val: 128}, 0}, - {"sfixed64 - gte & lte - invalid (above)", &cases.SFixed64GTELTE{Val: 300}, 1}, - {"sfixed64 - gte & lte - invalid (below)", &cases.SFixed64GTELTE{Val: 100}, 1}, - {"sfixed64 - exclusive gte & lte - valid (above)", &cases.SFixed64ExGTELTE{Val: 300}, 0}, - {"sfixed64 - exclusive gte & lte - valid (below)", &cases.SFixed64ExGTELTE{Val: 100}, 0}, - {"sfixed64 - exclusive gte & lte - valid (max)", &cases.SFixed64ExGTELTE{Val: 256}, 0}, - {"sfixed64 - exclusive gte & lte - valid (min)", &cases.SFixed64ExGTELTE{Val: 128}, 0}, - {"sfixed64 - exclusive gte & lte - invalid", &cases.SFixed64ExGTELTE{Val: 200}, 1}, - {"sfixed64 - ignore_empty gte & lte - valid", &cases.SFixed64Ignore{Val: 0}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestBoolCases() { - tests := []TestCase{ - {"bool - none - valid", &cases.BoolNone{Val: true}, 0}, - {"bool - const (true) - valid", &cases.BoolConstTrue{Val: true}, 0}, - {"bool - const (true) - invalid", &cases.BoolConstTrue{Val: false}, 1}, - {"bool - const (false) - valid", &cases.BoolConstFalse{Val: false}, 0}, - {"bool - const (false) - invalid", &cases.BoolConstFalse{Val: true}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestStringCases() { - tests := []TestCase{ - {"string - none - valid", &cases.StringNone{Val: "quux"}, 0}, - {"string - const - valid", &cases.StringConst{Val: "foo"}, 0}, - {"string - const - invalid", &cases.StringConst{Val: "bar"}, 1}, - {"string - in - valid", &cases.StringIn{Val: "bar"}, 0}, - {"string - in - invalid", &cases.StringIn{Val: "quux"}, 1}, - {"string - not in - valid", &cases.StringNotIn{Val: "quux"}, 0}, - {"string - not in - invalid", &cases.StringNotIn{Val: "fizz"}, 1}, - {"string - len - valid", &cases.StringLen{Val: "baz"}, 0}, - {"string - len - valid (multibyte)", &cases.StringLen{Val: "你好吖"}, 0}, - {"string - len - invalid (lt)", &cases.StringLen{Val: "go"}, 1}, - {"string - len - invalid (gt)", &cases.StringLen{Val: "fizz"}, 1}, - {"string - len - invalid (multibyte)", &cases.StringLen{Val: "你好"}, 1}, - {"string - min len - valid", &cases.StringMinLen{Val: "protoc"}, 0}, - {"string - min len - valid (min)", &cases.StringMinLen{Val: "baz"}, 0}, - {"string - min len - invalid", &cases.StringMinLen{Val: "go"}, 1}, - {"string - min len - invalid (multibyte)", &cases.StringMinLen{Val: "你好"}, 1}, - {"string - max len - valid", &cases.StringMaxLen{Val: "foo"}, 0}, - {"string - max len - valid (max)", &cases.StringMaxLen{Val: "proto"}, 0}, - {"string - max len - valid (multibyte)", &cases.StringMaxLen{Val: "你好你好"}, 0}, - {"string - max len - invalid", &cases.StringMaxLen{Val: "1234567890"}, 1}, - {"string - min/max len - valid", &cases.StringMinMaxLen{Val: "quux"}, 0}, - {"string - min/max len - valid (min)", &cases.StringMinMaxLen{Val: "foo"}, 0}, - {"string - min/max len - valid (max)", &cases.StringMinMaxLen{Val: "proto"}, 0}, - {"string - min/max len - valid (multibyte)", &cases.StringMinMaxLen{Val: "你好你好"}, 0}, - {"string - min/max len - invalid (below)", &cases.StringMinMaxLen{Val: "go"}, 1}, - {"string - min/max len - invalid (above)", &cases.StringMinMaxLen{Val: "validate"}, 1}, - {"string - equal min/max len - valid", &cases.StringEqualMinMaxLen{Val: "proto"}, 0}, - {"string - equal min/max len - invalid", &cases.StringEqualMinMaxLen{Val: "validate"}, 1}, - {"string - len bytes - valid", &cases.StringLenBytes{Val: "pace"}, 0}, - {"string - len bytes - invalid (lt)", &cases.StringLenBytes{Val: "val"}, 1}, - {"string - len bytes - invalid (gt)", &cases.StringLenBytes{Val: "world"}, 1}, - {"string - len bytes - invalid (multibyte)", &cases.StringLenBytes{Val: "世界和平"}, 1}, - {"string - min bytes - valid", &cases.StringMinBytes{Val: "proto"}, 0}, - {"string - min bytes - valid (min)", &cases.StringMinBytes{Val: "quux"}, 0}, - {"string - min bytes - valid (multibyte)", &cases.StringMinBytes{Val: "你好"}, 0}, - {"string - min bytes - invalid", &cases.StringMinBytes{Val: ""}, 1}, - {"string - max bytes - valid", &cases.StringMaxBytes{Val: "foo"}, 0}, - {"string - max bytes - valid (max)", &cases.StringMaxBytes{Val: "12345678"}, 0}, - {"string - max bytes - invalid", &cases.StringMaxBytes{Val: "123456789"}, 1}, - {"string - max bytes - invalid (multibyte)", &cases.StringMaxBytes{Val: "你好你好你好"}, 1}, - {"string - min/max bytes - valid", &cases.StringMinMaxBytes{Val: "protoc"}, 0}, - {"string - min/max bytes - valid (min)", &cases.StringMinMaxBytes{Val: "quux"}, 0}, - {"string - min/max bytes - valid (max)", &cases.StringMinMaxBytes{Val: "fizzbuzz"}, 0}, - {"string - min/max bytes - valid (multibyte)", &cases.StringMinMaxBytes{Val: "你好"}, 0}, - {"string - min/max bytes - invalid (below)", &cases.StringMinMaxBytes{Val: "foo"}, 1}, - {"string - min/max bytes - invalid (above)", &cases.StringMinMaxBytes{Val: "你好你好你"}, 1}, - {"string - equal min/max bytes - valid", &cases.StringEqualMinMaxBytes{Val: "protoc"}, 0}, - {"string - equal min/max bytes - invalid", &cases.StringEqualMinMaxBytes{Val: "foo"}, 1}, - {"string - pattern - valid", &cases.StringPattern{Val: "Foo123"}, 0}, - {"string - pattern - invalid", &cases.StringPattern{Val: "!@#$%^&*()"}, 1}, - {"string - pattern - invalid (empty)", &cases.StringPattern{Val: ""}, 1}, - {"string - pattern - invalid (null)", &cases.StringPattern{Val: "a\000"}, 1}, - {"string - pattern (escapes) - valid", &cases.StringPatternEscapes{Val: "* \\ x"}, 0}, - {"string - pattern (escapes) - invalid", &cases.StringPatternEscapes{Val: "invalid"}, 1}, - {"string - pattern (escapes) - invalid (empty)", &cases.StringPatternEscapes{Val: ""}, 1}, - {"string - prefix - valid", &cases.StringPrefix{Val: "foobar"}, 0}, - {"string - prefix - valid (only)", &cases.StringPrefix{Val: "foo"}, 0}, - {"string - prefix - invalid", &cases.StringPrefix{Val: "bar"}, 1}, - {"string - prefix - invalid (case-sensitive)", &cases.StringPrefix{Val: "Foobar"}, 1}, - {"string - contains - valid", &cases.StringContains{Val: "candy bars"}, 0}, - {"string - contains - valid (only)", &cases.StringContains{Val: "bar"}, 0}, - {"string - contains - invalid", &cases.StringContains{Val: "candy bazs"}, 1}, - {"string - contains - invalid (case-sensitive)", &cases.StringContains{Val: "Candy Bars"}, 1}, - {"string - not contains - valid", &cases.StringNotContains{Val: "candy bazs"}, 0}, - {"string - not contains - valid (case-sensitive)", &cases.StringNotContains{Val: "Candy Bars"}, 0}, - {"string - not contains - invalid", &cases.StringNotContains{Val: "candy bars"}, 1}, - {"string - not contains - invalid (equal)", &cases.StringNotContains{Val: "bar"}, 1}, - {"string - suffix - valid", &cases.StringSuffix{Val: "foobaz"}, 0}, - {"string - suffix - valid (only)", &cases.StringSuffix{Val: "baz"}, 0}, - {"string - suffix - invalid", &cases.StringSuffix{Val: "foobar"}, 1}, - {"string - suffix - invalid (case-sensitive)", &cases.StringSuffix{Val: "FooBaz"}, 1}, - {"string - email - valid", &cases.StringEmail{Val: "foo@bar.com"}, 0}, - {"string - email - valid (name)", &cases.StringEmail{Val: "John Smith "}, 0}, - {"string - email - invalid", &cases.StringEmail{Val: "foobar"}, 1}, - {"string - email - invalid (local segment too long)", &cases.StringEmail{Val: "x0123456789012345678901234567890123456789012345678901234567890123456789@example.com"}, 1}, - {"string - email - invalid (hostname too long)", &cases.StringEmail{Val: "foo@x0123456789012345678901234567890123456789012345678901234567890123456789.com"}, 1}, - {"string - email - invalid (bad hostname)", &cases.StringEmail{Val: "foo@-bar.com"}, 1}, - {"string - email - empty", &cases.StringEmail{Val: ""}, 1}, - {"string - address - valid hostname", &cases.StringAddress{Val: "example.com"}, 0}, - {"string - address - valid hostname (uppercase)", &cases.StringAddress{Val: "ASD.example.com"}, 0}, - {"string - address - valid hostname (hyphens)", &cases.StringAddress{Val: "foo-bar.com"}, 0}, - {"string - address - valid hostname (trailing dot)", &cases.StringAddress{Val: "example.com."}, 0}, - {"string - address - invalid hostname", &cases.StringAddress{Val: "!@#$%^&"}, 1}, - {"string - address - invalid hostname (underscore)", &cases.StringAddress{Val: "foo_bar.com"}, 1}, - {"string - address - invalid hostname (too long)", &cases.StringAddress{Val: "x0123456789012345678901234567890123456789012345678901234567890123456789.com"}, 1}, - {"string - address - invalid hostname (trailing hyphens)", &cases.StringAddress{Val: "foo-bar-.com"}, 1}, - {"string - address - invalid hostname (leading hyphens)", &cases.StringAddress{Val: "foo-bar.-com"}, 1}, - {"string - address - invalid hostname (empty)", &cases.StringAddress{Val: "asd..asd.com"}, 1}, - {"string - address - invalid hostname (IDNs)", &cases.StringAddress{Val: "你好.com"}, 1}, - {"string - address - valid ip (v4)", &cases.StringAddress{Val: "192.168.0.1"}, 0}, - {"string - address - valid ip (v6)", &cases.StringAddress{Val: "3e::99"}, 0}, - {"string - address - invalid ip", &cases.StringAddress{Val: "ff::fff::0b"}, 1}, - {"string - hostname - valid", &cases.StringHostname{Val: "example.com"}, 0}, - {"string - hostname - valid (uppercase)", &cases.StringHostname{Val: "ASD.example.com"}, 0}, - {"string - hostname - valid (hyphens)", &cases.StringHostname{Val: "foo-bar.com"}, 0}, - {"string - hostname - valid (trailing dot)", &cases.StringHostname{Val: "example.com."}, 0}, - {"string - hostname - invalid", &cases.StringHostname{Val: "!@#$%^&"}, 1}, - {"string - hostname - invalid (underscore)", &cases.StringHostname{Val: "foo_bar.com"}, 1}, - {"string - hostname - invalid (too long)", &cases.StringHostname{Val: "x0123456789012345678901234567890123456789012345678901234567890123456789.com"}, 1}, - {"string - hostname - invalid (trailing hyphens)", &cases.StringHostname{Val: "foo-bar-.com"}, 1}, - {"string - hostname - invalid (leading hyphens)", &cases.StringHostname{Val: "foo-bar.-com"}, 1}, - {"string - hostname - invalid (empty)", &cases.StringHostname{Val: "asd..asd.com"}, 1}, - {"string - hostname - invalid (IDNs)", &cases.StringHostname{Val: "你好.com"}, 1}, - {"string - IP - valid (v4)", &cases.StringIP{Val: "192.168.0.1"}, 0}, - {"string - IP - valid (v6)", &cases.StringIP{Val: "3e::99"}, 0}, - {"string - IP - invalid", &cases.StringIP{Val: "foobar"}, 1}, - {"string - IPv4 - valid", &cases.StringIPv4{Val: "192.168.0.1"}, 0}, - {"string - IPv4 - invalid", &cases.StringIPv4{Val: "foobar"}, 1}, - {"string - IPv4 - invalid (erroneous)", &cases.StringIPv4{Val: "256.0.0.0"}, 1}, - {"string - IPv4 - invalid (v6)", &cases.StringIPv4{Val: "3e::99"}, 1}, - {"string - IPv6 - valid", &cases.StringIPv6{Val: "2001:0db8:85a3:0000:0000:8a2e:0370:7334"}, 0}, - {"string - IPv6 - valid (collapsed)", &cases.StringIPv6{Val: "2001:db8:85a3::8a2e:370:7334"}, 0}, - {"string - IPv6 - invalid", &cases.StringIPv6{Val: "foobar"}, 1}, - {"string - IPv6 - invalid (v4)", &cases.StringIPv6{Val: "192.168.0.1"}, 1}, - {"string - IPv6 - invalid (erroneous)", &cases.StringIPv6{Val: "ff::fff::0b"}, 1}, - {"string - URI - valid", &cases.StringURI{Val: "http://example.com/foo/bar?baz=quux"}, 0}, - {"string - URI - invalid", &cases.StringURI{Val: "!@#$%^&*%$#"}, 1}, - {"string - URI - invalid (relative)", &cases.StringURI{Val: "/foo/bar?baz=quux"}, 1}, - {"string - URI - valid", &cases.StringURIRef{Val: "http://example.com/foo/bar?baz=quux"}, 0}, - {"string - URI - valid (relative)", &cases.StringURIRef{Val: "/foo/bar?baz=quux"}, 0}, - {"string - URI - invalid", &cases.StringURIRef{Val: "!@#$%^&*%$#"}, 1}, - {"string - UUID - valid (nil)", &cases.StringUUID{Val: "00000000-0000-0000-0000-000000000000"}, 0}, - {"string - UUID - valid (v1)", &cases.StringUUID{Val: "b45c0c80-8880-11e9-a5b1-000000000000"}, 0}, - {"string - UUID - valid (v1 - case-insensitive)", &cases.StringUUID{Val: "B45C0C80-8880-11E9-A5B1-000000000000"}, 0}, - {"string - UUID - valid (v2)", &cases.StringUUID{Val: "b45c0c80-8880-21e9-a5b1-000000000000"}, 0}, - {"string - UUID - valid (v2 - case-insensitive)", &cases.StringUUID{Val: "B45C0C80-8880-21E9-A5B1-000000000000"}, 0}, - {"string - UUID - valid (v3)", &cases.StringUUID{Val: "a3bb189e-8bf9-3888-9912-ace4e6543002"}, 0}, - {"string - UUID - valid (v3 - case-insensitive)", &cases.StringUUID{Val: "A3BB189E-8BF9-3888-9912-ACE4E6543002"}, 0}, - {"string - UUID - valid (v4)", &cases.StringUUID{Val: "8b208305-00e8-4460-a440-5e0dcd83bb0a"}, 0}, - {"string - UUID - valid (v4 - case-insensitive)", &cases.StringUUID{Val: "8B208305-00E8-4460-A440-5E0DCD83BB0A"}, 0}, - {"string - UUID - valid (v5)", &cases.StringUUID{Val: "a6edc906-2f9f-5fb2-a373-efac406f0ef2"}, 0}, - {"string - UUID - valid (v5 - case-insensitive)", &cases.StringUUID{Val: "A6EDC906-2F9F-5FB2-A373-EFAC406F0EF2"}, 0}, - {"string - UUID - invalid", &cases.StringUUID{Val: "foobar"}, 1}, - {"string - UUID - invalid (bad UUID)", &cases.StringUUID{Val: "ffffffff-ffff-ffff-ffff-fffffffffffff"}, 1}, - {"string - UUID - valid (ignore_empty)", &cases.StringUUIDIgnore{Val: ""}, 0}, - {"string - http header name - valid", &cases.StringHttpHeaderName{Val: "clustername"}, 0}, - {"string - http header name - valid", &cases.StringHttpHeaderName{Val: ":path"}, 0}, - {"string - http header name - valid (nums)", &cases.StringHttpHeaderName{Val: "cluster-123"}, 0}, - {"string - http header name - valid (special token)", &cases.StringHttpHeaderName{Val: "!+#&.%"}, 0}, - {"string - http header name - valid (period)", &cases.StringHttpHeaderName{Val: "CLUSTER.NAME"}, 0}, - {"string - http header name - invalid", &cases.StringHttpHeaderName{Val: ":"}, 1}, - {"string - http header name - invalid", &cases.StringHttpHeaderName{Val: ":path:"}, 1}, - {"string - http header name - invalid (space)", &cases.StringHttpHeaderName{Val: "cluster name"}, 1}, - {"string - http header name - invalid (return)", &cases.StringHttpHeaderName{Val: "example\r"}, 1}, - {"string - http header name - invalid (tab)", &cases.StringHttpHeaderName{Val: "example\t"}, 1}, - {"string - http header name - invalid (slash)", &cases.StringHttpHeaderName{Val: "/test/long/url"}, 1}, - {"string - http header value - valid", &cases.StringHttpHeaderValue{Val: "cluster.name.123"}, 0}, - {"string - http header value - valid (uppercase)", &cases.StringHttpHeaderValue{Val: "/TEST/LONG/URL"}, 0}, - {"string - http header value - valid (spaces)", &cases.StringHttpHeaderValue{Val: "cluster name"}, 0}, - {"string - http header value - valid (tab)", &cases.StringHttpHeaderValue{Val: "example\t"}, 0}, - {"string - http header value - valid (special token)", &cases.StringHttpHeaderValue{Val: "!#%&./+"}, 0}, - {"string - http header value - invalid (NUL)", &cases.StringHttpHeaderValue{Val: "foo\u0000bar"}, 1}, - {"string - http header value - invalid (DEL)", &cases.StringHttpHeaderValue{Val: "\u007f"}, 1}, - {"string - http header value - invalid", &cases.StringHttpHeaderValue{Val: "example\r"}, 1}, - {"string - non-strict valid header - valid", &cases.StringValidHeader{Val: "cluster.name.123"}, 0}, - {"string - non-strict valid header - valid (uppercase)", &cases.StringValidHeader{Val: "/TEST/LONG/URL"}, 0}, - {"string - non-strict valid header - valid (spaces)", &cases.StringValidHeader{Val: "cluster name"}, 0}, - {"string - non-strict valid header - valid (tab)", &cases.StringValidHeader{Val: "example\t"}, 0}, - {"string - non-strict valid header - valid (DEL)", &cases.StringValidHeader{Val: "\u007f"}, 0}, - {"string - non-strict valid header - invalid (NUL)", &cases.StringValidHeader{Val: "foo\u0000bar"}, 1}, - {"string - non-strict valid header - invalid (CR)", &cases.StringValidHeader{Val: "example\r"}, 1}, - {"string - non-strict valid header - invalid (NL)", &cases.StringValidHeader{Val: "exa\u000Ample"}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestBytesCases() { - tests := []TestCase{ - {"bytes - none - valid", &cases.BytesNone{Val: []byte("quux")}, 0}, - {"bytes - const - valid", &cases.BytesConst{Val: []byte("foo")}, 0}, - {"bytes - const - invalid", &cases.BytesConst{Val: []byte("bar")}, 1}, - {"bytes - in - valid", &cases.BytesIn{Val: []byte("bar")}, 0}, - {"bytes - in - invalid", &cases.BytesIn{Val: []byte("quux")}, 1}, - {"bytes - not in - valid", &cases.BytesNotIn{Val: []byte("quux")}, 0}, - {"bytes - not in - invalid", &cases.BytesNotIn{Val: []byte("fizz")}, 1}, - {"bytes - len - valid", &cases.BytesLen{Val: []byte("baz")}, 0}, - {"bytes - len - invalid (lt)", &cases.BytesLen{Val: []byte("go")}, 1}, - {"bytes - len - invalid (gt)", &cases.BytesLen{Val: []byte("fizz")}, 1}, - {"bytes - min len - valid", &cases.BytesMinLen{Val: []byte("fizz")}, 0}, - {"bytes - min len - valid (min)", &cases.BytesMinLen{Val: []byte("baz")}, 0}, - {"bytes - min len - invalid", &cases.BytesMinLen{Val: []byte("go")}, 1}, - {"bytes - max len - valid", &cases.BytesMaxLen{Val: []byte("foo")}, 0}, - {"bytes - max len - valid (max)", &cases.BytesMaxLen{Val: []byte("proto")}, 0}, - {"bytes - max len - invalid", &cases.BytesMaxLen{Val: []byte("1234567890")}, 1}, - {"bytes - min/max len - valid", &cases.BytesMinMaxLen{Val: []byte("quux")}, 0}, - {"bytes - min/max len - valid (min)", &cases.BytesMinMaxLen{Val: []byte("foo")}, 0}, - {"bytes - min/max len - valid (max)", &cases.BytesMinMaxLen{Val: []byte("proto")}, 0}, - {"bytes - min/max len - invalid (below)", &cases.BytesMinMaxLen{Val: []byte("go")}, 1}, - {"bytes - min/max len - invalid (above)", &cases.BytesMinMaxLen{Val: []byte("validate")}, 1}, - {"bytes - equal min/max len - valid", &cases.BytesEqualMinMaxLen{Val: []byte("proto")}, 0}, - {"bytes - equal min/max len - invalid", &cases.BytesEqualMinMaxLen{Val: []byte("validate")}, 1}, - {"bytes - pattern - valid", &cases.BytesPattern{Val: []byte("Foo123")}, 0}, - {"bytes - pattern - invalid", &cases.BytesPattern{Val: []byte("你好你好")}, 1}, - {"bytes - pattern - invalid (empty)", &cases.BytesPattern{Val: []byte("")}, 1}, - {"bytes - prefix - valid", &cases.BytesPrefix{Val: []byte{0x99, 0x9f, 0x08}}, 0}, - {"bytes - prefix - valid (only)", &cases.BytesPrefix{Val: []byte{0x99}}, 0}, - {"bytes - prefix - invalid", &cases.BytesPrefix{Val: []byte("bar")}, 1}, - {"bytes - contains - valid", &cases.BytesContains{Val: []byte("candy bars")}, 0}, - {"bytes - contains - valid (only)", &cases.BytesContains{Val: []byte("bar")}, 0}, - {"bytes - contains - invalid", &cases.BytesContains{Val: []byte("candy bazs")}, 1}, - {"bytes - suffix - valid", &cases.BytesSuffix{Val: []byte{0x62, 0x75, 0x7A, 0x7A}}, 0}, - {"bytes - suffix - valid (only)", &cases.BytesSuffix{Val: []byte("\x62\x75\x7A\x7A")}, 0}, - {"bytes - suffix - invalid", &cases.BytesSuffix{Val: []byte("foobar")}, 1}, - {"bytes - suffix - invalid (case-sensitive)", &cases.BytesSuffix{Val: []byte("FooBaz")}, 1}, - {"bytes - IP - valid (v4)", &cases.BytesIP{Val: []byte{0xC0, 0xA8, 0x00, 0x01}}, 0}, - {"bytes - IP - valid (v6)", &cases.BytesIP{Val: []byte("\x20\x01\x0D\xB8\x85\xA3\x00\x00\x00\x00\x8A\x2E\x03\x70\x73\x34")}, 0}, - {"bytes - IP - invalid", &cases.BytesIP{Val: []byte("foobar")}, 1}, - {"bytes - IPv4 - valid", &cases.BytesIPv4{Val: []byte{0xC0, 0xA8, 0x00, 0x01}}, 0}, - {"bytes - IPv4 - invalid", &cases.BytesIPv4{Val: []byte("foobar")}, 1}, - {"bytes - IPv4 - invalid (v6)", &cases.BytesIPv4{Val: []byte("\x20\x01\x0D\xB8\x85\xA3\x00\x00\x00\x00\x8A\x2E\x03\x70\x73\x34")}, 1}, - {"bytes - IPv6 - valid", &cases.BytesIPv6{Val: []byte("\x20\x01\x0D\xB8\x85\xA3\x00\x00\x00\x00\x8A\x2E\x03\x70\x73\x34")}, 0}, - {"bytes - IPv6 - invalid", &cases.BytesIPv6{Val: []byte("fooar")}, 1}, - {"bytes - IPv6 - invalid (v4)", &cases.BytesIPv6{Val: []byte{0xC0, 0xA8, 0x00, 0x01}}, 1}, - {"bytes - IPv6 - valid (ignore_empty)", &cases.BytesIPv6Ignore{Val: nil}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestEnumCases() { - tests := []TestCase{ - {"enum - none - valid", &cases.EnumNone{Val: cases.TestEnum_TEST_ENUM_ONE}, 0}, - {"enum - const - valid", &cases.EnumConst{Val: cases.TestEnum_TEST_ENUM_TWO}, 0}, - {"enum - const - invalid", &cases.EnumConst{Val: cases.TestEnum_TEST_ENUM_ONE}, 1}, - {"enum alias - const - valid", &cases.EnumAliasConst{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_C}, 0}, - {"enum alias - const - valid (alias)", &cases.EnumAliasConst{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_GAMMA}, 0}, - {"enum alias - const - invalid", &cases.EnumAliasConst{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_ALPHA}, 1}, - {"enum - defined_only - valid", &cases.EnumDefined{Val: 0}, 0}, - {"enum - defined_only - invalid", &cases.EnumDefined{Val: math.MaxInt32}, 1}, - {"enum alias - defined_only - valid", &cases.EnumAliasDefined{Val: 1}, 0}, - {"enum alias - defined_only - invalid", &cases.EnumAliasDefined{Val: math.MaxInt32}, 1}, - {"enum - in - valid", &cases.EnumIn{Val: cases.TestEnum_TEST_ENUM_TWO}, 0}, - {"enum - in - invalid", &cases.EnumIn{Val: cases.TestEnum_TEST_ENUM_ONE}, 1}, - {"enum alias - in - valid", &cases.EnumAliasIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_A}, 0}, - {"enum alias - in - valid (alias)", &cases.EnumAliasIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_ALPHA}, 0}, - {"enum alias - in - invalid", &cases.EnumAliasIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_BETA}, 1}, - {"enum - not in - valid", &cases.EnumNotIn{Val: cases.TestEnum_TEST_ENUM_ONE}, 0}, - {"enum - not in - valid (undefined)", &cases.EnumNotIn{Val: math.MaxInt32}, 0}, - {"enum - not in - invalid", &cases.EnumNotIn{Val: cases.TestEnum_TEST_ENUM_ONE}, 1}, - {"enum alias - not in - valid", &cases.EnumAliasNotIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_ALPHA}, 0}, - {"enum alias - not in - invalid", &cases.EnumAliasNotIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_B}, 1}, - {"enum alias - not in - invalid (alias)", &cases.EnumAliasNotIn{Val: cases.TestEnumAlias_TEST_ENUM_ALIAS_BETA}, 1}, - {"enum external - defined_only - valid", &cases.EnumExternal{Val: otherpackage.Embed_ENUMERATED_VALUE}, 0}, - {"enum external - defined_only - invalid", &cases.EnumExternal{Val: math.MaxInt32}, 1}, - {"enum repeated - defined_only - valid", &cases.RepeatedEnumDefined{Val: []cases.TestEnum{cases.TestEnum_TEST_ENUM_ONE, cases.TestEnum_TEST_ENUM_TWO}}, 0}, - {"enum repeated - defined_only - invalid", &cases.RepeatedEnumDefined{Val: []cases.TestEnum{cases.TestEnum_TEST_ENUM_ONE, math.MaxInt32}}, 1}, - {"enum repeated (external) - defined_only - valid", &cases.RepeatedExternalEnumDefined{Val: []otherpackage.Embed_Enumerated{otherpackage.Embed_ENUMERATED_VALUE}}, 0}, - {"enum repeated (external) - defined_only - invalid", &cases.RepeatedExternalEnumDefined{Val: []otherpackage.Embed_Enumerated{math.MaxInt32}}, 1}, - {"enum repeated (another external) - defined_only - valid", &cases.RepeatedYetAnotherExternalEnumDefined{Val: []yetanotherpackage.Embed_Enumerated{yetanotherpackage.Embed_ENUMERATED_VALUE}}, 0}, - {"enum map - defined_only - valid", &cases.MapEnumDefined{Val: map[string]cases.TestEnum{"foo": cases.TestEnum_TEST_ENUM_TWO}}, 0}, - {"enum map - defined_only - invalid", &cases.MapEnumDefined{Val: map[string]cases.TestEnum{"foo": math.MaxInt32}}, 1}, - {"enum map (external) - defined_only - valid", &cases.MapExternalEnumDefined{Val: map[string]otherpackage.Embed_Enumerated{"foo": otherpackage.Embed_ENUMERATED_VALUE}}, 0}, - {"enum map (external) - defined_only - invalid", &cases.MapExternalEnumDefined{Val: map[string]otherpackage.Embed_Enumerated{"foo": math.MaxInt32}}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestMessageCases() { - tests := []TestCase{ - {"message - none - valid", &cases.MessageNone{Val: &cases.MessageNone_NoneMsg{}}, 0}, - {"message - none - valid (unset)", &cases.MessageNone{}, 0}, - {"message - disabled - valid", &cases.MessageDisabled{Val: 456}, 0}, - {"message - disabled - valid (invalid field)", &cases.MessageDisabled{Val: 0}, 0}, - // TODO(TCN-1552): causing infinite recursion - // {"message - field - valid", &cases.Message{Val: &cases.TestMsg{Const: "foo"}}, 0}, - // {"message - field - valid (unset)", &cases.Message{}, 0}, - // {"message - field - invalid", &cases.Message{Val: &cases.TestMsg{}}, 1}, - // {"message - field - invalid (transitive)", &cases.Message{Val: &cases.TestMsg{Const: "foo", Nested: &cases.TestMsg{}}}, 1}, - // {"message - skip - valid", &cases.MessageSkip{Val: &cases.TestMsg{}}, 0}, - // {"message - required - valid", &cases.MessageRequired{Val: &cases.TestMsg{Const: "foo"}}, 0}, - // {"message - required - valid (oneof)", &cases.MessageRequiredOneof{One: &cases.MessageRequiredOneof_Val{Val: &cases.TestMsg{Const: "foo"}}}, 0}, - // {"message - required - invalid", &cases.MessageRequired{}, 1}, - // {"message - required - invalid (oneof)", &cases.MessageRequiredOneof{}, 1}, - // {"message - required - valid", &cases.MessageRequiredButOptional{Val: &cases.TestMsg{Const: "foo"}}, 0}, - // {"message - required - valid (unset)", &cases.MessageRequiredButOptional{}, 0}, - // {"message - cross-package embed none - valid", &cases.MessageCrossPackage{Val: &other_packagev2.Embed{Val: 1}}, 0}, - // {"message - cross-package embed none - valid (nil)", &cases.MessageCrossPackage{}, 0}, - // {"message - cross-package embed none - valid (empty)", &cases.MessageCrossPackage{Val: &other_packagev2.Embed{}}, 1}, - // {"message - cross-package embed none - invalid", &cases.MessageCrossPackage{Val: &other_packagev2.Embed{Val: -1}}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestRepeatedCases() { - tests := []TestCase{ - {"repeated - none - valid", &cases.RepeatedNone{Val: []int64{1, 2, 3}}, 0}, - {"repeated - embed none - valid", &cases.RepeatedEmbedNone{Val: []*cases.Embed{{Val: 1}}}, 0}, - {"repeated - embed none - valid (nil)", &cases.RepeatedEmbedNone{}, 0}, - {"repeated - embed none - valid (empty)", &cases.RepeatedEmbedNone{Val: []*cases.Embed{}}, 0}, - {"repeated - embed none - invalid", &cases.RepeatedEmbedNone{Val: []*cases.Embed{{Val: -1}}}, 1}, - {"repeated - cross-package embed none - valid", &cases.RepeatedEmbedCrossPackageNone{Val: []*otherpackage.Embed{{Val: 1}}}, 0}, - {"repeated - cross-package embed none - valid (nil)", &cases.RepeatedEmbedCrossPackageNone{}, 0}, - {"repeated - cross-package embed none - valid (empty)", &cases.RepeatedEmbedCrossPackageNone{Val: []*otherpackage.Embed{}}, 0}, - {"repeated - cross-package embed none - invalid", &cases.RepeatedEmbedCrossPackageNone{Val: []*otherpackage.Embed{{Val: -1}}}, 1}, - {"repeated - min - valid", &cases.RepeatedMin{Val: []*cases.Embed{{Val: 1}, {Val: 2}, {Val: 3}}}, 0}, - {"repeated - min - valid (equal)", &cases.RepeatedMin{Val: []*cases.Embed{{Val: 1}, {Val: 2}}}, 0}, - {"repeated - min - invalid", &cases.RepeatedMin{Val: []*cases.Embed{{Val: 1}}}, 1}, - {"repeated - min - invalid (element)", &cases.RepeatedMin{Val: []*cases.Embed{{Val: 1}, {Val: -1}}}, 1}, - {"repeated - max - valid", &cases.RepeatedMax{Val: []float64{1, 2}}, 0}, - {"repeated - max - valid (equal)", &cases.RepeatedMax{Val: []float64{1, 2, 3}}, 0}, - {"repeated - max - invalid", &cases.RepeatedMax{Val: []float64{1, 2, 3, 4}}, 1}, - {"repeated - min/max - valid", &cases.RepeatedMinMax{Val: []int32{1, 2, 3}}, 0}, - {"repeated - min/max - valid (min)", &cases.RepeatedMinMax{Val: []int32{1, 2}}, 0}, - {"repeated - min/max - valid (max)", &cases.RepeatedMinMax{Val: []int32{1, 2, 3, 4}}, 0}, - {"repeated - min/max - invalid (below)", &cases.RepeatedMinMax{Val: []int32{}}, 1}, - {"repeated - min/max - invalid (above)", &cases.RepeatedMinMax{Val: []int32{1, 2, 3, 4, 5}}, 1}, - {"repeated - exact - valid", &cases.RepeatedExact{Val: []uint32{1, 2, 3}}, 0}, - {"repeated - exact - invalid (below)", &cases.RepeatedExact{Val: []uint32{1, 2}}, 1}, - {"repeated - exact - invalid (above)", &cases.RepeatedExact{Val: []uint32{1, 2, 3, 4}}, 1}, - {"repeated - unique - valid", &cases.RepeatedUnique{Val: []string{"foo", "bar", "baz"}}, 0}, - {"repeated - unique - valid (empty)", &cases.RepeatedUnique{}, 0}, - {"repeated - unique - valid (case sensitivity)", &cases.RepeatedUnique{Val: []string{"foo", "Foo"}}, 0}, - {"repeated - unique - invalid", &cases.RepeatedUnique{Val: []string{"foo", "bar", "foo", "baz"}}, 1}, - {"repeated - items - valid", &cases.RepeatedItemRule{Val: []float32{1, 2, 3}}, 0}, - {"repeated - items - valid (empty)", &cases.RepeatedItemRule{Val: []float32{}}, 0}, - {"repeated - items - valid (pattern)", &cases.RepeatedItemPattern{Val: []string{"Alpha", "Beta123"}}, 0}, - {"repeated - items - invalid", &cases.RepeatedItemRule{Val: []float32{1, -2, 3}}, 1}, - {"repeated - items - invalid (pattern)", &cases.RepeatedItemPattern{Val: []string{"Alpha", "!@#$%^&*()"}}, 1}, - {"repeated - items - invalid (in)", &cases.RepeatedItemIn{Val: []string{"baz"}}, 1}, - {"repeated - items - valid (in)", &cases.RepeatedItemIn{Val: []string{"foo"}}, 0}, - {"repeated - items - invalid (not_in)", &cases.RepeatedItemNotIn{Val: []string{"foo"}}, 1}, - {"repeated - items - valid (not_in)", &cases.RepeatedItemNotIn{Val: []string{"baz"}}, 0}, - {"repeated - items - invalid (enum in)", &cases.RepeatedEnumIn{Val: []cases.AnEnum{1}}, 1}, - {"repeated - items - valid (enum in)", &cases.RepeatedEnumIn{Val: []cases.AnEnum{0}}, 0}, - {"repeated - items - invalid (enum not_in)", &cases.RepeatedEnumNotIn{Val: []cases.AnEnum{0}}, 1}, - {"repeated - items - valid (enum not_in)", &cases.RepeatedEnumNotIn{Val: []cases.AnEnum{1}}, 0}, - {"repeated - items - invalid (embedded enum in)", &cases.RepeatedEmbeddedEnumIn{Val: []cases.RepeatedEmbeddedEnumIn_AnotherInEnum{1}}, 1}, - {"repeated - items - valid (embedded enum in)", &cases.RepeatedEmbeddedEnumIn{Val: []cases.RepeatedEmbeddedEnumIn_AnotherInEnum{0}}, 0}, - {"repeated - items - invalid (embedded enum not_in)", &cases.RepeatedEmbeddedEnumNotIn{Val: []cases.RepeatedEmbeddedEnumNotIn_AnotherNotInEnum{0}}, 1}, - {"repeated - items - valid (embedded enum not_in)", &cases.RepeatedEmbeddedEnumNotIn{Val: []cases.RepeatedEmbeddedEnumNotIn_AnotherNotInEnum{1}}, 0}, - {"repeated - items - invalid (any in)", &cases.RepeatedAnyIn{Val: []*anypb.Any{{TypeUrl: "type.googleapis.com/google.protobuf.Timestamp"}}}, 1}, - {"repeated - items - valid (any in)", &cases.RepeatedAnyIn{Val: []*anypb.Any{{TypeUrl: "type.googleapis.com/google.protobuf.Duration"}}}, 0}, - {"repeated - items - invalid (any not_in)", &cases.RepeatedAnyNotIn{Val: []*anypb.Any{{TypeUrl: "type.googleapis.com/google.protobuf.Timestamp"}}}, 1}, - {"repeated - items - valid (any not_in)", &cases.RepeatedAnyNotIn{Val: []*anypb.Any{{TypeUrl: "type.googleapis.com/google.protobuf.Duration"}}}, 0}, - {"repeated - embed skip - valid", &cases.RepeatedEmbedSkip{Val: []*cases.Embed{{Val: 1}}}, 0}, - {"repeated - embed skip - valid (invalid element)", &cases.RepeatedEmbedSkip{Val: []*cases.Embed{{Val: -1}}}, 0}, - {"repeated - min and items len - valid", &cases.RepeatedMinAndItemLen{Val: []string{"aaa", "bbb"}}, 0}, - {"repeated - min and items len - invalid (min)", &cases.RepeatedMinAndItemLen{Val: []string{}}, 1}, - {"repeated - min and items len - invalid (len)", &cases.RepeatedMinAndItemLen{Val: []string{"x"}}, 1}, - {"repeated - min and max items len - valid", &cases.RepeatedMinAndMaxItemLen{Val: []string{"aaa", "bbb"}}, 0}, - {"repeated - min and max items len - invalid (min_len)", &cases.RepeatedMinAndMaxItemLen{}, 1}, - {"repeated - min and max items len - invalid (max_len)", &cases.RepeatedMinAndMaxItemLen{Val: []string{"aaa", "bbb", "ccc", "ddd"}}, 1}, - {"repeated - duration - gte - valid", &cases.RepeatedDuration{Val: []*durationpb.Duration{{Seconds: 3}}}, 0}, - {"repeated - duration - gte - valid (empty)", &cases.RepeatedDuration{}, 0}, - {"repeated - duration - gte - valid (equal)", &cases.RepeatedDuration{Val: []*durationpb.Duration{{Nanos: 1000000}}}, 0}, - {"repeated - duration - gte - invalid", &cases.RepeatedDuration{Val: []*durationpb.Duration{{Seconds: -1}}}, 1}, - {"repeated - exact - valid (ignore_empty)", &cases.RepeatedExactIgnore{Val: nil}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestMapCases() { - tests := []TestCase{ - {"map - none - valid", &cases.MapNone{Val: map[uint32]bool{123: true, 456: false}}, 0}, - {"map - min pairs - valid", &cases.MapMin{Val: map[int32]float32{1: 2, 3: 4, 5: 6}}, 0}, - {"map - min pairs - valid (equal)", &cases.MapMin{Val: map[int32]float32{1: 2, 3: 4}}, 0}, - {"map - min pairs - invalid", &cases.MapMin{Val: map[int32]float32{1: 2}}, 1}, - {"map - max pairs - valid", &cases.MapMax{Val: map[int64]float64{1: 2, 3: 4}}, 0}, - {"map - max pairs - valid (equal)", &cases.MapMax{Val: map[int64]float64{1: 2, 3: 4, 5: 6}}, 0}, - {"map - max pairs - invalid", &cases.MapMax{Val: map[int64]float64{1: 2, 3: 4, 5: 6, 7: 8}}, 1}, - {"map - min/max - valid", &cases.MapMinMax{Val: map[string]bool{"a": true, "b": false, "c": true}}, 0}, - {"map - min/max - valid (min)", &cases.MapMinMax{Val: map[string]bool{"a": true, "b": false}}, 0}, - {"map - min/max - valid (max)", &cases.MapMinMax{Val: map[string]bool{"a": true, "b": false, "c": true, "d": false}}, 0}, - {"map - min/max - invalid (below)", &cases.MapMinMax{Val: map[string]bool{}}, 1}, - {"map - min/max - invalid (above)", &cases.MapMinMax{Val: map[string]bool{"a": true, "b": false, "c": true, "d": false, "e": true}}, 1}, - {"map - exact - valid", &cases.MapExact{Val: map[uint64]string{1: "a", 2: "b", 3: "c"}}, 0}, - {"map - exact - invalid (below)", &cases.MapExact{Val: map[uint64]string{1: "a", 2: "b"}}, 1}, - {"map - exact - invalid (above)", &cases.MapExact{Val: map[uint64]string{1: "a", 2: "b", 3: "c", 4: "d"}}, 1}, - {"map - no sparse - valid", &cases.MapNoSparse{Val: map[uint32]*cases.MapNoSparse_Msg{1: {}, 2: {}}}, 0}, - {"map - no sparse - valid (empty)", &cases.MapNoSparse{Val: map[uint32]*cases.MapNoSparse_Msg{}}, 0}, - // sparse maps are not currently longer supported, so this case is no longer possible - // {"map - no sparse - invalid", &cases.MapNoSparse{Val: map[uint32]*cases.MapNoSparse_Msg{1: {}, 2: nil}}, 1}, - {"map - keys - valid", &cases.MapKeys{Val: map[int64]string{-1: "a", -2: "b"}}, 0}, - {"map - keys - valid (empty)", &cases.MapKeys{Val: map[int64]string{}}, 0}, - {"map - keys - valid (pattern)", &cases.MapKeysPattern{Val: map[string]string{"A": "a"}}, 0}, - {"map - keys - invalid", &cases.MapKeys{Val: map[int64]string{1: "a"}}, 1}, - {"map - keys - invalid (pattern)", &cases.MapKeysPattern{Val: map[string]string{"A": "a", "!@#$%^&*()": "b"}}, 1}, - {"map - values - valid", &cases.MapValues{Val: map[string]string{"a": "Alpha", "b": "Beta"}}, 0}, - {"map - values - valid (empty)", &cases.MapValues{Val: map[string]string{}}, 0}, - {"map - values - valid (pattern)", &cases.MapValuesPattern{Val: map[string]string{"a": "A"}}, 0}, - {"map - values - invalid", &cases.MapValues{Val: map[string]string{"a": "A", "b": "B"}}, 2}, - {"map - values - invalid (pattern)", &cases.MapValuesPattern{Val: map[string]string{"a": "A", "b": "!@#$%^&*()"}}, 1}, - {"map - recursive - valid", &cases.MapRecursive{Val: map[uint32]*cases.MapRecursive_Msg{1: {Val: "abc"}}}, 0}, - {"map - recursive - invalid", &cases.MapRecursive{Val: map[uint32]*cases.MapRecursive_Msg{1: {}}}, 1}, - {"map - exact - valid (ignore_empty)", &cases.MapExactIgnore{Val: nil}, 0}, - {"map - multiple - valid", &cases.MultipleMaps{First: map[uint32]string{1: "a", 2: "b"}, Second: map[int32]bool{-1: true, -2: false}}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestOneofCases() { - tests := []TestCase{ - // TODO(TCN-1558): oneof is not currently supported - // {"oneof - none - valid", &cases.OneOfNone{O: &cases.OneOfNone_X{X: "foo"}}, 0}, - // {"oneof - none - valid (empty)", &cases.OneOfNone{}, 0}, - // {"oneof - field - valid (X)", &cases.OneOf{O: &cases.OneOf_X{X: "foobar"}}, 0}, - // {"oneof - field - valid (Y)", &cases.OneOf{O: &cases.OneOf_Y{Y: 123}}, 0}, - // {"oneof - field - valid (Z)", &cases.OneOf{O: &cases.OneOf_Z{Z: &cases.TestOneOfMsg{Val: true}}}, 0}, - // {"oneof - field - valid (empty)", &cases.OneOf{}, 0}, - // {"oneof - field - invalid (X)", &cases.OneOf{O: &cases.OneOf_X{X: "fizzbuzz"}}, 1}, - // {"oneof - field - invalid (Y)", &cases.OneOf{O: &cases.OneOf_Y{Y: -1}}, 1}, - // {"oneof - filed - invalid (Z)", &cases.OneOf{O: &cases.OneOf_Z{Z: &cases.TestOneOfMsg{}}}, 1}, - // {"oneof - required - valid", &cases.OneOfRequired{O: &cases.OneOfRequired_X{X: ""}}, 0}, - // {"oneof - require - invalid", &cases.OneOfRequired{}, 1}, - // {"oneof - ignore_empty - valid (X)", &cases.OneOfIgnoreEmpty{O: &cases.OneOfIgnoreEmpty_X{X: ""}}, 0}, - // {"oneof - ignore_empty - valid (Y)", &cases.OneOfIgnoreEmpty{O: &cases.OneOfIgnoreEmpty_Y{Y: []byte("")}}, 0}, - // {"oneof - ignore_empty - valid (Z)", &cases.OneOfIgnoreEmpty{O: &cases.OneOfIgnoreEmpty_Z{Z: 0}}, 0}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestWrapperCases() { - tests := []TestCase{ - // TODO(TCN-1556): add support for wrapper types - // {"wrapper - none - valid", &cases.WrapperNone{Val: &wrapperspb.Int32Value{Value: 123}}, 0}, - // {"wrapper - none - valid (empty)", &cases.WrapperNone{Val: nil}, 0}, - // {"wrapper - float - valid", &cases.WrapperFloat{Val: &wrapperspb.FloatValue{Value: 1}}, 0}, - // {"wrapper - float - valid (empty)", &cases.WrapperFloat{Val: nil}, 0}, - // {"wrapper - float - invalid", &cases.WrapperFloat{Val: &wrapperspb.FloatValue{Value: 0}}, 1}, - // {"wrapper - double - valid", &cases.WrapperDouble{Val: &wrapperspb.DoubleValue{Value: 1}}, 0}, - // {"wrapper - double - valid (empty)", &cases.WrapperDouble{Val: nil}, 0}, - // {"wrapper - double - invalid", &cases.WrapperDouble{Val: &wrapperspb.DoubleValue{Value: 0}}, 1}, - // {"wrapper - int64 - valid", &cases.WrapperInt64{Val: &wrapperspb.Int64Value{Value: 1}}, 0}, - // {"wrapper - int64 - valid (empty)", &cases.WrapperInt64{Val: nil}, 0}, - // {"wrapper - int64 - invalid", &cases.WrapperInt64{Val: &wrapperspb.Int64Value{Value: 0}}, 1}, - // {"wrapper - int32 - valid", &cases.WrapperInt32{Val: &wrapperspb.Int32Value{Value: 1}}, 0}, - // {"wrapper - int32 - valid (empty)", &cases.WrapperInt32{Val: nil}, 0}, - // {"wrapper - int32 - invalid", &cases.WrapperInt32{Val: &wrapperspb.Int32Value{Value: 0}}, 1}, - // {"wrapper - uint64 - valid", &cases.WrapperUInt64{Val: &wrapperspb.UInt64Value{Value: 1}}, 0}, - // {"wrapper - uint64 - valid (empty)", &cases.WrapperUInt64{Val: nil}, 0}, - // {"wrapper - uint64 - invalid", &cases.WrapperUInt64{Val: &wrapperspb.UInt64Value{Value: 0}}, 1}, - // {"wrapper - uint32 - valid", &cases.WrapperUInt32{Val: &wrapperspb.UInt32Value{Value: 1}}, 0}, - // {"wrapper - uint32 - valid (empty)", &cases.WrapperUInt32{Val: nil}, 0}, - // {"wrapper - uint32 - invalid", &cases.WrapperUInt32{Val: &wrapperspb.UInt32Value{Value: 0}}, 1}, - // {"wrapper - bool - valid", &cases.WrapperBool{Val: &wrapperspb.BoolValue{Value: true}}, 0}, - // {"wrapper - bool - valid (empty)", &cases.WrapperBool{Val: nil}, 0}, - // {"wrapper - bool - invalid", &cases.WrapperBool{Val: &wrapperspb.BoolValue{Value: false}}, 1}, - // {"wrapper - string - valid", &cases.WrapperString{Val: &wrapperspb.StringValue{Value: "foobar"}}, 0}, - // {"wrapper - string - valid (empty)", &cases.WrapperString{Val: nil}, 0}, - // {"wrapper - string - invalid", &cases.WrapperString{Val: &wrapperspb.StringValue{Value: "fizzbuzz"}}, 1}, - // {"wrapper - bytes - valid", &cases.WrapperBytes{Val: &wrapperspb.BytesValue{Value: []byte("foo")}}, 0}, - // {"wrapper - bytes - valid (empty)", &cases.WrapperBytes{Val: nil}, 0}, - // {"wrapper - bytes - invalid", &cases.WrapperBytes{Val: &wrapperspb.BytesValue{Value: []byte("x")}}, 1}, - // {"wrapper - required - string - valid", &cases.WrapperRequiredString{Val: &wrapperspb.StringValue{Value: "bar"}}, 0}, - // {"wrapper - required - string - invalid", &cases.WrapperRequiredString{Val: &wrapperspb.StringValue{Value: "foo"}}, 1}, - // {"wrapper - required - string - invalid (empty)", &cases.WrapperRequiredString{}, 1}, - // {"wrapper - required - string (empty) - valid", &cases.WrapperRequiredEmptyString{Val: &wrapperspb.StringValue{Value: ""}}, 0}, - // {"wrapper - required - string (empty) - invalid", &cases.WrapperRequiredEmptyString{Val: &wrapperspb.StringValue{Value: "foo"}}, 1}, - // {"wrapper - required - string (empty) - invalid (empty)", &cases.WrapperRequiredEmptyString{}, 1}, - // {"wrapper - optional - string (uuid) - valid", &cases.WrapperOptionalUuidString{Val: &wrapperspb.StringValue{Value: "8b72987b-024a-43b3-b4cf-647a1f925c5d"}}, 0}, - // {"wrapper - optional - string (uuid) - valid (empty)", &cases.WrapperOptionalUuidString{}, 0}, - // {"wrapper - optional - string (uuid) - invalid", &cases.WrapperOptionalUuidString{Val: &wrapperspb.StringValue{Value: "foo"}}, 1}, - // {"wrapper - required - float - valid", &cases.WrapperRequiredFloat{Val: &wrapperspb.FloatValue{Value: 1}}, 0}, - // {"wrapper - required - float - invalid", &cases.WrapperRequiredFloat{Val: &wrapperspb.FloatValue{Value: -5}}, 1}, - // {"wrapper - required - float - invalid (empty)", &cases.WrapperRequiredFloat{}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestDurationCases() { - tests := []TestCase{ - {"duration - none - valid", &cases.DurationNone{Val: &durationpb.Duration{Seconds: 123}}, 0}, - {"duration - required - valid", &cases.DurationRequired{Val: &durationpb.Duration{}}, 0}, - {"duration - required - invalid", &cases.DurationRequired{Val: nil}, 1}, - {"duration - const - valid", &cases.DurationConst{Val: &durationpb.Duration{Seconds: 3}}, 0}, - {"duration - const - valid (empty)", &cases.DurationConst{}, 0}, - {"duration - const - invalid", &cases.DurationConst{Val: &durationpb.Duration{Nanos: 3}}, 1}, - {"duration - in - valid", &cases.DurationIn{Val: &durationpb.Duration{Seconds: 1}}, 0}, - {"duration - in - valid (empty)", &cases.DurationIn{}, 0}, - {"duration - in - invalid", &cases.DurationIn{Val: &durationpb.Duration{}}, 1}, - {"duration - not in - valid", &cases.DurationNotIn{Val: &durationpb.Duration{Nanos: 1}}, 0}, - {"duration - not in - valid (empty)", &cases.DurationNotIn{}, 0}, - {"duration - not in - invalid", &cases.DurationNotIn{Val: &durationpb.Duration{}}, 1}, - {"duration - lt - valid", &cases.DurationLT{Val: &durationpb.Duration{Nanos: -1}}, 0}, - {"duration - lt - valid (empty)", &cases.DurationLT{}, 0}, - {"duration - lt - invalid (equal)", &cases.DurationLT{Val: &durationpb.Duration{}}, 1}, - {"duration - lt - invalid", &cases.DurationLT{Val: &durationpb.Duration{Seconds: 1}}, 1}, - {"duration - lte - valid", &cases.DurationLTE{Val: &durationpb.Duration{}}, 0}, - {"duration - lte - valid (empty)", &cases.DurationLTE{}, 0}, - {"duration - lte - valid (equal)", &cases.DurationLTE{Val: &durationpb.Duration{Seconds: 1}}, 0}, - {"duration - lte - invalid", &cases.DurationLTE{Val: &durationpb.Duration{Seconds: 1, Nanos: 1}}, 1}, - {"duration - gt - valid", &cases.DurationGT{Val: &durationpb.Duration{Seconds: 1}}, 0}, - {"duration - gt - valid (empty)", &cases.DurationGT{}, 0}, - {"duration - gt - invalid (equal)", &cases.DurationGT{Val: &durationpb.Duration{Nanos: 1000}}, 1}, - {"duration - gt - invalid", &cases.DurationGT{Val: &durationpb.Duration{}}, 1}, - {"duration - gte - valid", &cases.DurationGTE{Val: &durationpb.Duration{Seconds: 3}}, 0}, - {"duration - gte - valid (empty)", &cases.DurationGTE{}, 0}, - {"duration - gte - valid (equal)", &cases.DurationGTE{Val: &durationpb.Duration{Nanos: 1000000}}, 0}, - {"duration - gte - invalid", &cases.DurationGTE{Val: &durationpb.Duration{Seconds: -1}}, 1}, - {"duration - gt & lt - valid", &cases.DurationGTLT{Val: &durationpb.Duration{Nanos: 1000}}, 0}, - {"duration - gt & lt - valid (empty)", &cases.DurationGTLT{}, 0}, - {"duration - gt & lt - invalid (above)", &cases.DurationGTLT{Val: &durationpb.Duration{Seconds: 1000}}, 1}, - {"duration - gt & lt - invalid (below)", &cases.DurationGTLT{Val: &durationpb.Duration{Nanos: -1000}}, 1}, - {"duration - gt & lt - invalid (max)", &cases.DurationGTLT{Val: &durationpb.Duration{Seconds: 1}}, 1}, - {"duration - gt & lt - invalid (min)", &cases.DurationGTLT{Val: &durationpb.Duration{}}, 1}, - {"duration - exclusive gt & lt - valid (empty)", &cases.DurationExLTGT{}, 0}, - {"duration - exclusive gt & lt - valid (above)", &cases.DurationExLTGT{Val: &durationpb.Duration{Seconds: 2}}, 0}, - {"duration - exclusive gt & lt - valid (below)", &cases.DurationExLTGT{Val: &durationpb.Duration{Nanos: -1}}, 0}, - {"duration - exclusive gt & lt - invalid", &cases.DurationExLTGT{Val: &durationpb.Duration{Nanos: 1000}}, 1}, - {"duration - exclusive gt & lt - invalid (max)", &cases.DurationExLTGT{Val: &durationpb.Duration{Seconds: 1}}, 1}, - {"duration - exclusive gt & lt - invalid (min)", &cases.DurationExLTGT{Val: &durationpb.Duration{}}, 1}, - {"duration - gte & lte - valid", &cases.DurationGTELTE{Val: &durationpb.Duration{Seconds: 60, Nanos: 1}}, 0}, - {"duration - gte & lte - valid (empty)", &cases.DurationGTELTE{}, 0}, - {"duration - gte & lte - valid (max)", &cases.DurationGTELTE{Val: &durationpb.Duration{Seconds: 3600}}, 0}, - {"duration - gte & lte - valid (min)", &cases.DurationGTELTE{Val: &durationpb.Duration{Seconds: 60}}, 0}, - {"duration - gte & lte - invalid (above)", &cases.DurationGTELTE{Val: &durationpb.Duration{Seconds: 3600, Nanos: 1}}, 1}, - {"duration - gte & lte - invalid (below)", &cases.DurationGTELTE{Val: &durationpb.Duration{Seconds: 59}}, 1}, - {"duration - gte & lte - valid (empty)", &cases.DurationExGTELTE{}, 0}, - {"duration - exclusive gte & lte - valid (above)", &cases.DurationExGTELTE{Val: &durationpb.Duration{Seconds: 3601}}, 0}, - {"duration - exclusive gte & lte - valid (below)", &cases.DurationExGTELTE{Val: &durationpb.Duration{}}, 0}, - {"duration - exclusive gte & lte - valid (max)", &cases.DurationExGTELTE{Val: &durationpb.Duration{Seconds: 3600}}, 0}, - {"duration - exclusive gte & lte - valid (min)", &cases.DurationExGTELTE{Val: &durationpb.Duration{Seconds: 60}}, 0}, - {"duration - exclusive gte & lte - invalid", &cases.DurationExGTELTE{Val: &durationpb.Duration{Seconds: 61}}, 1}, - {"duration - fields with other fields - invalid other field", &cases.DurationFieldWithOtherFields{DurationVal: nil, IntVal: 12}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestTimestampCases() { - tests := []TestCase{ - {"timestamp - none - valid", &cases.TimestampNone{Val: ×tamppb.Timestamp{Seconds: 123}}, 0}, - {"timestamp - required - valid", &cases.TimestampRequired{Val: ×tamppb.Timestamp{}}, 0}, - {"timestamp - required - invalid", &cases.TimestampRequired{Val: nil}, 1}, - {"timestamp - const - valid", &cases.TimestampConst{Val: ×tamppb.Timestamp{Seconds: 3}}, 0}, - {"timestamp - const - valid (empty)", &cases.TimestampConst{}, 0}, - {"timestamp - const - invalid", &cases.TimestampConst{Val: ×tamppb.Timestamp{Nanos: 3}}, 1}, - {"timestamp - lt - valid", &cases.TimestampLT{Val: ×tamppb.Timestamp{Seconds: -1}}, 0}, - {"timestamp - lt - valid (empty)", &cases.TimestampLT{}, 0}, - {"timestamp - lt - invalid (equal)", &cases.TimestampLT{Val: ×tamppb.Timestamp{}}, 1}, - {"timestamp - lt - invalid", &cases.TimestampLT{Val: ×tamppb.Timestamp{Seconds: 1}}, 1}, - {"timestamp - lte - valid", &cases.TimestampLTE{Val: ×tamppb.Timestamp{}}, 0}, - {"timestamp - lte - valid (empty)", &cases.TimestampLTE{}, 0}, - {"timestamp - lte - valid (equal)", &cases.TimestampLTE{Val: ×tamppb.Timestamp{Seconds: 1}}, 0}, - {"timestamp - lte - invalid", &cases.TimestampLTE{Val: ×tamppb.Timestamp{Seconds: 1, Nanos: 1}}, 1}, - {"timestamp - gt - valid", &cases.TimestampGT{Val: ×tamppb.Timestamp{Seconds: 1}}, 0}, - {"timestamp - gt - valid (empty)", &cases.TimestampGT{}, 0}, - {"timestamp - gt - invalid (equal)", &cases.TimestampGT{Val: ×tamppb.Timestamp{Nanos: 1000}}, 1}, - {"timestamp - gt - invalid", &cases.TimestampGT{Val: ×tamppb.Timestamp{}}, 1}, - {"timestamp - gte - valid", &cases.TimestampGTE{Val: ×tamppb.Timestamp{Seconds: 3}}, 0}, - {"timestamp - gte - valid (empty)", &cases.TimestampGTE{}, 0}, - {"timestamp - gte - valid (equal)", &cases.TimestampGTE{Val: ×tamppb.Timestamp{Nanos: 1000000}}, 0}, - {"timestamp - gte - invalid", &cases.TimestampGTE{Val: ×tamppb.Timestamp{Seconds: -1}}, 1}, - {"timestamp - gt & lt - valid", &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Nanos: 1000}}, 0}, - {"timestamp - gt & lt - valid (empty)", &cases.TimestampGTLT{}, 0}, - {"timestamp - gt & lt - invalid (above)", &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: 1000}}, 1}, - {"timestamp - gt & lt - invalid (below)", &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: -1000}}, 1}, - {"timestamp - gt & lt - invalid (max)", &cases.TimestampGTLT{Val: ×tamppb.Timestamp{Seconds: 1}}, 1}, - {"timestamp - gt & lt - invalid (min)", &cases.TimestampGTLT{Val: ×tamppb.Timestamp{}}, 1}, - {"timestamp - exclusive gt & lt - valid (empty)", &cases.TimestampExLTGT{}, 0}, - {"timestamp - exclusive gt & lt - valid (above)", &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Seconds: 2}}, 0}, - {"timestamp - exclusive gt & lt - valid (below)", &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Seconds: -1}}, 0}, - {"timestamp - exclusive gt & lt - invalid", &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Nanos: 1000}}, 1}, - {"timestamp - exclusive gt & lt - invalid (max)", &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{Seconds: 1}}, 1}, - {"timestamp - exclusive gt & lt - invalid (min)", &cases.TimestampExLTGT{Val: ×tamppb.Timestamp{}}, 1}, - {"timestamp - gte & lte - valid", &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 60, Nanos: 1}}, 0}, - {"timestamp - gte & lte - valid (empty)", &cases.TimestampGTELTE{}, 0}, - {"timestamp - gte & lte - valid (max)", &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 3600}}, 0}, - {"timestamp - gte & lte - valid (min)", &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 60}}, 0}, - {"timestamp - gte & lte - invalid (above)", &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 3600, Nanos: 1}}, 1}, - {"timestamp - gte & lte - invalid (below)", &cases.TimestampGTELTE{Val: ×tamppb.Timestamp{Seconds: 59}}, 1}, - {"timestamp - gte & lte - valid (empty)", &cases.TimestampExGTELTE{}, 0}, - {"timestamp - exclusive gte & lte - valid (above)", &cases.TimestampExGTELTE{Val: ×tamppb.Timestamp{Seconds: 3601}}, 0}, - {"timestamp - exclusive gte & lte - valid (below)", &cases.TimestampExGTELTE{Val: ×tamppb.Timestamp{}}, 0}, - {"timestamp - exclusive gte & lte - valid (max)", &cases.TimestampExGTELTE{Val: ×tamppb.Timestamp{Seconds: 3600}}, 0}, - {"timestamp - exclusive gte & lte - valid (min)", &cases.TimestampExGTELTE{Val: ×tamppb.Timestamp{Seconds: 60}}, 0}, - {"timestamp - exclusive gte & lte - invalid", &cases.TimestampExGTELTE{Val: ×tamppb.Timestamp{Seconds: 61}}, 1}, - {"timestamp - lt now - valid", &cases.TimestampLTNow{Val: ×tamppb.Timestamp{}}, 0}, - {"timestamp - lt now - valid (empty)", &cases.TimestampLTNow{}, 0}, - {"timestamp - lt now - invalid", &cases.TimestampLTNow{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, 1}, - {"timestamp - gt now - valid", &cases.TimestampGTNow{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, 0}, - {"timestamp - gt now - valid (empty)", &cases.TimestampGTNow{}, 0}, - {"timestamp - gt now - invalid", &cases.TimestampGTNow{Val: ×tamppb.Timestamp{}}, 1}, - {"timestamp - within - valid", &cases.TimestampWithin{Val: timestamppb.Now()}, 0}, - {"timestamp - within - valid (empty)", &cases.TimestampWithin{}, 0}, - {"timestamp - within - invalid (below)", &cases.TimestampWithin{Val: ×tamppb.Timestamp{}}, 1}, - {"timestamp - within - invalid (above)", &cases.TimestampWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, 1}, - {"timestamp - lt now within - valid", &cases.TimestampLTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() - 1800}}, 0}, - {"timestamp - lt now within - valid (empty)", &cases.TimestampLTNowWithin{}, 0}, - {"timestamp - lt now within - invalid (lt)", &cases.TimestampLTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 1800}}, 1}, - {"timestamp - lt now within - invalid (within)", &cases.TimestampLTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() - 7200}}, 1}, - {"timestamp - gt now within - valid", &cases.TimestampGTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 1800}}, 0}, - {"timestamp - gt now within - valid (empty)", &cases.TimestampGTNowWithin{}, 0}, - {"timestamp - gt now within - invalid (gt)", &cases.TimestampGTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() - 1800}}, 1}, - {"timestamp - gt now within - invalid (within)", &cases.TimestampGTNowWithin{Val: ×tamppb.Timestamp{Seconds: time.Now().Unix() + 7200}}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestAnyCases() { - tests := []TestCase{ - {"any - none - valid", &cases.AnyNone{Val: &anypb.Any{}}, 0}, - {"any - required - valid", &cases.AnyRequired{Val: &anypb.Any{}}, 0}, - {"any - required - invalid", &cases.AnyRequired{Val: nil}, 1}, - {"any - in - valid", &cases.AnyIn{Val: &anypb.Any{TypeUrl: "type.googleapis.com/google.protobuf.Duration"}}, 0}, - {"any - in - valid (empty)", &cases.AnyIn{}, 0}, - {"any - in - invalid", &cases.AnyIn{Val: &anypb.Any{TypeUrl: "type.googleapis.com/google.protobuf.Timestamp"}}, 1}, - {"any - not in - valid", &cases.AnyNotIn{Val: &anypb.Any{TypeUrl: "type.googleapis.com/google.protobuf.Duration"}}, 0}, - {"any - not in - valid (empty)", &cases.AnyNotIn{}, 0}, - {"any - not in - invalid", &cases.AnyNotIn{Val: &anypb.Any{TypeUrl: "type.googleapis.com/google.protobuf.Timestamp"}}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestKitchenSink() { - tests := []TestCase{ - // TODO(TCN-1552): causing infinite recursion - // {"kitchensink - field - valid", &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{Const: "abcd", IntConst: 5, BoolConst: false, FloatVal: &wrapperspb.FloatValue{Value: 1}, DurVal: &durationpb.Duration{Seconds: 3}, TsVal: ×tamppb.Timestamp{Seconds: 17}, FloatConst: 7, DoubleIn: 123, EnumConst: cases.ComplexTestEnum_COMPLEX_TEST_ENUM_TWO, AnyVal: &anypb.Any{TypeUrl: "type.googleapis.com/google.protobuf.Duration"}, RepTsVal: []*timestamppb.Timestamp{{Seconds: 3}}, MapVal: map[int32]string{-1: "a", -2: "b"}, BytesVal: []byte("\x00\x99"), O: &cases.ComplexTestMsg_X{X: "foobar"}}}, 0}, - // {"kitchensink - valid (unset)", &cases.KitchenSinkMessage{}, 0}, - // {"kitchensink - field - invalid", &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{}}, 7}, - // {"kitchensink - field - embedded - invalid", &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{Another: &cases.ComplexTestMsg{}}}, 14}, - // {"kitchensink - field - invalid (transitive)", &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{Const: "abcd", BoolConst: true, Nested: &cases.ComplexTestMsg{}}}, 14}, - // {"kitchensink - many - all non-message fields invalid", &cases.KitchenSinkMessage{Val: &cases.ComplexTestMsg{BoolConst: true, FloatVal: &wrapperspb.FloatValue{}, TsVal: ×tamppb.Timestamp{}, FloatConst: 8, AnyVal: &anypb.Any{TypeUrl: "asdf"}, RepTsVal: []*timestamppb.Timestamp{{Nanos: 1}}}}, 13}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -} - -func (test *testSuite) TestNestedCases() { - tests := []TestCase{ - // TODO(TCN-1555 & TCN-1554): FieldRules `message` attribute not being evaluated - // {"nested wkt uuid - field - valid", &cases.WktLevelOne{Two: &cases.WktLevelOne_WktLevelTwo{Three: &cases.WktLevelOne_WktLevelTwo_WktLevelThree{Uuid: "f81d16ef-40e2-40c6-bebc-89aaf5292f9a"}}}, 0}, - // {"nested wkt uuid - field - invalid", &cases.WktLevelOne{Two: &cases.WktLevelOne_WktLevelTwo{Three: &cases.WktLevelOne_WktLevelTwo_WktLevelThree{Uuid: "not-a-valid-uuid"}}}, 1}, - } - for _, testCase := range tests { - test.Run(testCase.name, func() { - runTest(testCase, test) - }) - } -}