// Code generated by protoc-gen-validate. DO NOT EDIT. // source: conf/v1/kratos_conf_bootstrap.proto package conf 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 Bootstrap 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 *Bootstrap) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Bootstrap with the rules defined in // the proto definition for this message. If any rules are violated, the // result is a list of violation errors wrapped in BootstrapMultiError, or nil // if none found. func (m *Bootstrap) ValidateAll() error { return m.validate(true) } func (m *Bootstrap) validate(all bool) error { if m == nil { return nil } var errors []error if all { switch v := interface{}(m.GetServer()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Server", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Server", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetServer()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Server", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetClient()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Client", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Client", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetClient()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Client", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetData()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Data", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Data", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Data", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetTrace()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Trace", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Trace", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetTrace()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Trace", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetLogger()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Logger", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Logger", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetLogger()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Logger", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetRegistry()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Registry", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Registry", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetRegistry()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Registry", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetConfig()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetOss()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Oss", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Oss", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetOss()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Oss", reason: "embedded message failed validation", cause: err, } } } if all { switch v := interface{}(m.GetNotify()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Notify", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ field: "Notify", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetNotify()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ field: "Notify", reason: "embedded message failed validation", cause: err, } } } if len(errors) > 0 { return BootstrapMultiError(errors) } return nil } // BootstrapMultiError is an error wrapping multiple validation errors returned // by Bootstrap.ValidateAll() if the designated constraints aren't met. type BootstrapMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m BootstrapMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m BootstrapMultiError) AllErrors() []error { return m } // BootstrapValidationError is the validation error returned by // Bootstrap.Validate if the designated constraints aren't met. type BootstrapValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e BootstrapValidationError) Field() string { return e.field } // Reason function returns reason value. func (e BootstrapValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e BootstrapValidationError) Cause() error { return e.cause } // Key function returns key value. func (e BootstrapValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e BootstrapValidationError) ErrorName() string { return "BootstrapValidationError" } // Error satisfies the builtin error interface func (e BootstrapValidationError) 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 %sBootstrap.%s: %s%s", key, e.field, e.reason, cause) } var _ error = BootstrapValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = BootstrapValidationError{}