// Validate checks the field values on RouteMatch with the rules defined in the
// proto definition for this message. If any rules are violated, an error is returned.
545885
func (m *RouteMatch) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetCaseSensitive()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouteMatchValidationError{
					field:  "CaseSensitive",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetRuntimeFraction()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouteMatchValidationError{
					field:  "RuntimeFraction",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	for idx, item := range m.GetHeaders() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouteMatchValidationError{
						field:  fmt.Sprintf("Headers[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	for idx, item := range m.GetQueryParameters() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouteMatchValidationError{
						field:  fmt.Sprintf("QueryParameters[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	{
		tmp := m.GetGrpc()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouteMatchValidationError{
					field:  "Grpc",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	switch m.PathSpecifier.(type) {

	case *RouteMatch_Prefix:
		// no validation rules for Prefix

	case *RouteMatch_Path:
		// no validation rules for Path

	case *RouteMatch_Regex:

		if len(m.GetRegex()) > 1024 {
			return RouteMatchValidationError{
				field:  "Regex",
				reason: "value length must be at most 1024 bytes",
			}
		}

	default:
		return RouteMatchValidationError{
			field:  "PathSpecifier",
			reason: "value is required",
		}

	}

	return nil
}
318665
func (s *MapSchema) Validate(v reflect.Value) bool {
	v = dereference(v)

	return v.Kind() == reflect.Map && v.Type().Key().Kind() == reflect.String
}
63609
func (m *ExtAuthzPerRoute) Validate() error {
	if m == nil {
		return nil
	}

	switch m.Override.(type) {

	case *ExtAuthzPerRoute_Disabled:

		if m.GetDisabled() != true {
			return ExtAuthzPerRouteValidationError{
				field:  "Disabled",
				reason: "value must equal true",
			}
		}

	case *ExtAuthzPerRoute_CheckSettings:

		if m.GetCheckSettings() == nil {
			return ExtAuthzPerRouteValidationError{
				field:  "CheckSettings",
				reason: "value is required",
			}
		}

		{
			tmp := m.GetCheckSettings()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return ExtAuthzPerRouteValidationError{
						field:  "CheckSettings",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	default:
		return ExtAuthzPerRouteValidationError{
			field:  "Override",
			reason: "value is required",
		}

	}

	return nil
}
583140
func (m *HeaderMatcher) Validate() error {
	if m == nil {
		return nil
	}

	if len(m.GetName()) < 1 {
		return HeaderMatcherValidationError{
			field:  "Name",
			reason: "value length must be at least 1 bytes",
		}
	}

	// no validation rules for InvertMatch

	switch m.HeaderMatchSpecifier.(type) {

	case *HeaderMatcher_ExactMatch:
		// no validation rules for ExactMatch

	case *HeaderMatcher_RegexMatch:

		if len(m.GetRegexMatch()) > 1024 {
			return HeaderMatcherValidationError{
				field:  "RegexMatch",
				reason: "value length must be at most 1024 bytes",
			}
		}

	case *HeaderMatcher_RangeMatch:

		{
			tmp := m.GetRangeMatch()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HeaderMatcherValidationError{
						field:  "RangeMatch",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *HeaderMatcher_PresentMatch:
		// no validation rules for PresentMatch

	case *HeaderMatcher_PrefixMatch:

		if len(m.GetPrefixMatch()) < 1 {
			return HeaderMatcherValidationError{
				field:  "PrefixMatch",
				reason: "value length must be at least 1 bytes",
			}
		}

	case *HeaderMatcher_SuffixMatch:

		if len(m.GetSuffixMatch()) < 1 {
			return HeaderMatcherValidationError{
				field:  "SuffixMatch",
				reason: "value length must be at least 1 bytes",
			}
		}

	}

	return nil
}
70328
func (m *Body) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for Truncated

	switch m.BodyType.(type) {

	case *Body_AsBytes:
		// no validation rules for AsBytes

	case *Body_AsString:
		// no validation rules for AsString

	}

	return nil
}
752599
func (vl *Validator) Validate(v interface{}) error {
	return vl.validateStruct(reflect.ValueOf(v))
}
1081313
func (v *MatchRule) Validate(value interface{}) error {
	value, isNil := Indirect(value)
	if isNil {
		return nil
	}

	isString, str, isBytes, bs := StringOrBytes(value)
	if isString && (str == "" || v.re.MatchString(str)) {
		return nil
	} else if isBytes && (len(bs) == 0 || v.re.Match(bs)) {
		return nil
	}
	return errors.New(v.message)
}
64478
func (m *Route) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetMatch()

		if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouteValidationError{
					field:  "Match",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetMetadata()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouteValidationError{
					field:  "Metadata",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetDecorator()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouteValidationError{
					field:  "Decorator",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	// no validation rules for PerFilterConfig

	// no validation rules for TypedPerFilterConfig

	if len(m.GetRequestHeadersToAdd()) > 1000 {
		return RouteValidationError{
			field:  "RequestHeadersToAdd",
			reason: "value must contain no more than 1000 item(s)",
		}
	}

	for idx, item := range m.GetRequestHeadersToAdd() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouteValidationError{
						field:  fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	if len(m.GetResponseHeadersToAdd()) > 1000 {
		return RouteValidationError{
			field:  "ResponseHeadersToAdd",
			reason: "value must contain no more than 1000 item(s)",
		}
	}

	for idx, item := range m.GetResponseHeadersToAdd() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouteValidationError{
						field:  fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	switch m.Action.(type) {

	case *Route_Route:

		{
			tmp := m.GetRoute()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouteValidationError{
						field:  "Route",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *Route_Redirect:

		{
			tmp := m.GetRedirect()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouteValidationError{
						field:  "Redirect",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *Route_DirectResponse:

		{
			tmp := m.GetDirectResponse()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouteValidationError{
						field:  "DirectResponse",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	default:
		return RouteValidationError{
			field:  "Action",
			reason: "value is required",
		}

	}

	return nil
}
32318
func (s *Service) Validate() error {
	var mErr multierror.Error

	// Ensure the service name is valid per the below RFCs but make an exception
	// for our interpolation syntax by first stripping any environment variables from the name

	serviceNameStripped := args.ReplaceEnvWithPlaceHolder(s.Name, "ENV-VAR")

	if err := s.ValidateName(serviceNameStripped); err != nil {
		mErr.Errors = append(mErr.Errors, fmt.Errorf("service name must be valid per RFC 1123 and can contain only alphanumeric characters or dashes: %q", s.Name))
	}

	switch s.AddressMode {
	case "", AddressModeAuto, AddressModeHost, AddressModeDriver:
		// OK
	default:
		mErr.Errors = append(mErr.Errors, fmt.Errorf("service address_mode must be %q, %q, or %q; not %q", AddressModeAuto, AddressModeHost, AddressModeDriver, s.AddressMode))
	}

	for _, c := range s.Checks {
		if s.PortLabel == "" && c.PortLabel == "" && c.RequiresPort() {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("check %s invalid: check requires a port but neither check nor service %+q have a port", c.Name, s.Name))
			continue
		}

		if err := c.validate(); err != nil {
			mErr.Errors = append(mErr.Errors, fmt.Errorf("check %s invalid: %v", c.Name, err))
		}
	}

	return mErr.ErrorOrNil()
}
995267
func (m *Router) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetDynamicStats()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RouterValidationError{
					field:  "DynamicStats",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	// no validation rules for StartChildSpan

	for idx, item := range m.GetUpstreamLog() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return RouterValidationError{
						field:  fmt.Sprintf("UpstreamLog[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	// no validation rules for SuppressEnvoyHeaders

	return nil
}
1111145
func (v *Validator) Validate(x interface{}) error {
	jsv, err := v.validator()
	if err != nil {
		return err
	}
	return jsv.Validate(x)
}
312190
func (c *Config) Validate() error {
	if err := c.validateTemplates(); err != nil {
		return err
	}

	return nil
}
1043783
func (v *StringRule) Validate(value interface{}) error {
	value, isNil := Indirect(value)
	if isNil || IsEmpty(value) {
		return nil
	}

	str, err := EnsureString(value)
	if err != nil {
		return err
	}

	if v.validate(str) {
		return nil
	}
	return errors.New(v.message)
}
1338735
func (l4 L4Proto) Validate() error {
	switch l4 {
	case ProtoAny, ProtoTCP, ProtoUDP:
	default:
		return fmt.Errorf("invalid protocol %q, must be { tcp | udp | any }", l4)
	}

	return nil
}
1022948
func (pTypeDef *MapTest) Validate() error {
	if pTypeDef.Locations == nil {
		return fmt.Errorf("MapTest: Missing required field: locations")
	}
	return nil
}
573403
func (m *Mux) validate(rw http.ResponseWriter, req *http.Request) bool {
	plen := len(req.URL.Path)
	if plen > 1 && req.URL.Path[plen-1:] == "/" {
		cleanURL(&req.URL.Path)
		rw.Header().Set("Location", req.URL.String())
		rw.WriteHeader(http.StatusFound)
		return true
	}
	// Retry to find a route that match
	return m.parse(rw, req)
}
486381
func (m *RoutesConfigDump_StaticRouteConfig) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetRouteConfig()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RoutesConfigDump_StaticRouteConfigValidationError{
					field:  "RouteConfig",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetLastUpdated()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return RoutesConfigDump_StaticRouteConfigValidationError{
					field:  "LastUpdated",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	return nil
}