// Code generated by protoc-gen-validate. DO NOT EDIT.
// source: envoy/extensions/wasm/v3/wasm.proto

package envoy_extensions_wasm_v3

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

	"github.com/golang/protobuf/ptypes"
)

// 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)
	_ = ptypes.DynamicAny{}
)

// define the regex for a UUID once up-front
var _wasm_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")

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

	// no validation rules for VmId

	if len(m.GetRuntime()) < 1 {
		return VmConfigValidationError{
			field:  "Runtime",
			reason: "value length must be at least 1 bytes",
		}
	}

	if v, ok := interface{}(m.GetCode()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return VmConfigValidationError{
				field:  "Code",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	if v, ok := interface{}(m.GetConfiguration()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return VmConfigValidationError{
				field:  "Configuration",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	// no validation rules for AllowPrecompiled

	return nil
}

// VmConfigValidationError is the validation error returned by
// VmConfig.Validate if the designated constraints aren't met.
type VmConfigValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e VmConfigValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e VmConfigValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e VmConfigValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e VmConfigValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e VmConfigValidationError) ErrorName() string { return "VmConfigValidationError" }

// Error satisfies the builtin error interface
func (e VmConfigValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sVmConfig.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = VmConfigValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = VmConfigValidationError{}

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

	// no validation rules for Name

	// no validation rules for GroupName

	if v, ok := interface{}(m.GetConfiguration()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return PluginConfigValidationError{
				field:  "Configuration",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	switch m.VmConfig.(type) {

	case *PluginConfig_InlineVmConfig:

		if v, ok := interface{}(m.GetInlineVmConfig()).(interface{ Validate() error }); ok {
			if err := v.Validate(); err != nil {
				return PluginConfigValidationError{
					field:  "InlineVmConfig",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}

	}

	return nil
}

// PluginConfigValidationError is the validation error returned by
// PluginConfig.Validate if the designated constraints aren't met.
type PluginConfigValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e PluginConfigValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e PluginConfigValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e PluginConfigValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e PluginConfigValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e PluginConfigValidationError) ErrorName() string { return "PluginConfigValidationError" }

// Error satisfies the builtin error interface
func (e PluginConfigValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sPluginConfig.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = PluginConfigValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = PluginConfigValidationError{}

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

	if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
		if err := v.Validate(); err != nil {
			return WasmServiceValidationError{
				field:  "Config",
				reason: "embedded message failed validation",
				cause:  err,
			}
		}
	}

	// no validation rules for Singleton

	return nil
}

// WasmServiceValidationError is the validation error returned by
// WasmService.Validate if the designated constraints aren't met.
type WasmServiceValidationError struct {
	field  string
	reason string
	cause  error
	key    bool
}

// Field function returns field value.
func (e WasmServiceValidationError) Field() string { return e.field }

// Reason function returns reason value.
func (e WasmServiceValidationError) Reason() string { return e.reason }

// Cause function returns cause value.
func (e WasmServiceValidationError) Cause() error { return e.cause }

// Key function returns key value.
func (e WasmServiceValidationError) Key() bool { return e.key }

// ErrorName returns error name.
func (e WasmServiceValidationError) ErrorName() string { return "WasmServiceValidationError" }

// Error satisfies the builtin error interface
func (e WasmServiceValidationError) Error() string {
	cause := ""
	if e.cause != nil {
		cause = fmt.Sprintf(" | caused by: %v", e.cause)
	}

	key := ""
	if e.key {
		key = "key for "
	}

	return fmt.Sprintf(
		"invalid %sWasmService.%s: %s%s",
		key,
		e.field,
		e.reason,
		cause)
}

var _ error = WasmServiceValidationError{}

var _ interface {
	Field() string
	Reason() string
	Key() bool
	Cause() error
	ErrorName() string
} = WasmServiceValidationError{}
