1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: udpa/type/v1/typed_struct.proto
3
4package udpa_type_v1
5
6import (
7	"bytes"
8	"errors"
9	"fmt"
10	"net"
11	"net/mail"
12	"net/url"
13	"regexp"
14	"strings"
15	"time"
16	"unicode/utf8"
17
18	"github.com/golang/protobuf/ptypes"
19)
20
21// ensure the imports are used
22var (
23	_ = bytes.MinRead
24	_ = errors.New("")
25	_ = fmt.Print
26	_ = utf8.UTFMax
27	_ = (*regexp.Regexp)(nil)
28	_ = (*strings.Reader)(nil)
29	_ = net.IPv4len
30	_ = time.Duration(0)
31	_ = (*url.URL)(nil)
32	_ = (*mail.Address)(nil)
33	_ = ptypes.DynamicAny{}
34)
35
36// define the regex for a UUID once up-front
37var _typed_struct_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}$")
38
39// Validate checks the field values on TypedStruct with the rules defined in
40// the proto definition for this message. If any rules are violated, an error
41// is returned.
42func (m *TypedStruct) Validate() error {
43	if m == nil {
44		return nil
45	}
46
47	// no validation rules for TypeUrl
48
49	if v, ok := interface{}(m.GetValue()).(interface{ Validate() error }); ok {
50		if err := v.Validate(); err != nil {
51			return TypedStructValidationError{
52				field:  "Value",
53				reason: "embedded message failed validation",
54				cause:  err,
55			}
56		}
57	}
58
59	return nil
60}
61
62// TypedStructValidationError is the validation error returned by
63// TypedStruct.Validate if the designated constraints aren't met.
64type TypedStructValidationError struct {
65	field  string
66	reason string
67	cause  error
68	key    bool
69}
70
71// Field function returns field value.
72func (e TypedStructValidationError) Field() string { return e.field }
73
74// Reason function returns reason value.
75func (e TypedStructValidationError) Reason() string { return e.reason }
76
77// Cause function returns cause value.
78func (e TypedStructValidationError) Cause() error { return e.cause }
79
80// Key function returns key value.
81func (e TypedStructValidationError) Key() bool { return e.key }
82
83// ErrorName returns error name.
84func (e TypedStructValidationError) ErrorName() string { return "TypedStructValidationError" }
85
86// Error satisfies the builtin error interface
87func (e TypedStructValidationError) Error() string {
88	cause := ""
89	if e.cause != nil {
90		cause = fmt.Sprintf(" | caused by: %v", e.cause)
91	}
92
93	key := ""
94	if e.key {
95		key = "key for "
96	}
97
98	return fmt.Sprintf(
99		"invalid %sTypedStruct.%s: %s%s",
100		key,
101		e.field,
102		e.reason,
103		cause)
104}
105
106var _ error = TypedStructValidationError{}
107
108var _ interface {
109	Field() string
110	Reason() string
111	Key() bool
112	Cause() error
113	ErrorName() string
114} = TypedStructValidationError{}
115