You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: struct.pb.validate.go
    path of file: ./repos/hubble-ui/backend/vendor/github.com/cilium/proxy/go/envoy/type/matcher/v3
    
    the code of the file until where you have to start completion: // Code generated by protoc-gen-validate. DO NOT EDIT.
// source: envoy/type/matcher/v3/struct.proto

package matcherv3

import (
	"bytes"
	"errors"
	"fmt"
	"net"
	"net/mail"
	"net/url"
	"regexp"
	"sort"
	"strings"
	"time"
	"unicode/utf8"

	"google.golang.org/protobuf/types/known/anypb"
)

// ensure the imports are used
var (
	_ = bytes.MinRead
	_ = errors.New("")
	_ = fmt.Print
	_ = utf8.UTFMax
	_ = (*regexp.Regexp)(nil)
	_ = (*strings.Reader)(nil)
	_ = net.IPv4len
	_ = time.Duration(0)
	_ = (*url.URL)(nil)
	_ = (*mail.Address)(nil)
	_ = anypb.Any{}
	_ = sort.Sort
)

// Validate checks the field values on StructMatcher with the rules defined in
// the proto definition for this message. If any rules are violated, the first
// error encountered is returned, or nil if there are no violations.
func (m *StructMatcher) Validate() error {
	return m.validate(false)
}

// ValidateAll checks the field values on StructMatcher with the rules de
    
func (m *StructMatcher_PathSegment) validate(all bool) error {
	if m == nil {
		return nil
	}

	var errors []error

	oneofSegmentPresent := false
	switch v := m.Segment.(type) {
	case *StructMatcher_PathSegment_Key:
		if v == nil {
			err := StructMatcher_PathSegmentValidationError{
				field:  "Segment",
				reason: "oneof value cannot be a typed-nil",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}
		oneofSegmentPresent = true

		if utf8.RuneCountInString(m.GetKey()) < 1 {
			err := StructMatcher_PathSegmentValidationError{
				field:  "Key",
				reason: "value length must be at least 1 runes",
			}
			if !all {
				return err
			}
			errors = append(errors, err)
		}

	default:
		_ = v // ensures v is used
	}
	if !oneofSegmentPresent {
		err := StructMatcher_PathSegmentValidationError{
			field:  "Segment",
			reason: "value is required",
		}
		if !all {
			return err
		}
		errors = append(errors, err)
	}

	if len(errors) > 0 {
		return StructMatcher_PathSegmentMultiError(errors)
	}

	return nil
}