/internal/gen/proto/go/buf/module/v1/module.pb.validate.go

https://github.com/bufbuild/buf · Go · 287 lines · 175 code · 58 blank · 54 comment · 23 complexity · 321e2ccbde7b2488db361397a9b46092 MD5 · raw file

  1. // Copyright 2020 Buf Technologies, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by protoc-gen-validate. DO NOT EDIT.
  15. // source: buf/module/v1/module.proto
  16. package modulev1
  17. import (
  18. "bytes"
  19. "errors"
  20. "fmt"
  21. "net"
  22. "net/mail"
  23. "net/url"
  24. "regexp"
  25. "strings"
  26. "time"
  27. "unicode/utf8"
  28. "github.com/golang/protobuf/ptypes"
  29. )
  30. // ensure the imports are used
  31. var (
  32. _ = bytes.MinRead
  33. _ = errors.New("")
  34. _ = fmt.Print
  35. _ = utf8.UTFMax
  36. _ = (*regexp.Regexp)(nil)
  37. _ = (*strings.Reader)(nil)
  38. _ = net.IPv4len
  39. _ = time.Duration(0)
  40. _ = (*url.URL)(nil)
  41. _ = (*mail.Address)(nil)
  42. _ = ptypes.DynamicAny{}
  43. )
  44. // define the regex for a UUID once up-front
  45. var _module_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}$")
  46. // Validate checks the field values on Module with the rules defined in the
  47. // proto definition for this message. If any rules are violated, an error is returned.
  48. func (m *Module) Validate() error {
  49. if m == nil {
  50. return nil
  51. }
  52. for idx, item := range m.GetFiles() {
  53. _, _ = idx, item
  54. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  55. if err := v.Validate(); err != nil {
  56. return ModuleValidationError{
  57. field: fmt.Sprintf("Files[%v]", idx),
  58. reason: "embedded message failed validation",
  59. cause: err,
  60. }
  61. }
  62. }
  63. }
  64. for idx, item := range m.GetDependencies() {
  65. _, _ = idx, item
  66. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  67. if err := v.Validate(); err != nil {
  68. return ModuleValidationError{
  69. field: fmt.Sprintf("Dependencies[%v]", idx),
  70. reason: "embedded message failed validation",
  71. cause: err,
  72. }
  73. }
  74. }
  75. }
  76. return nil
  77. }
  78. // ModuleValidationError is the validation error returned by Module.Validate if
  79. // the designated constraints aren't met.
  80. type ModuleValidationError struct {
  81. field string
  82. reason string
  83. cause error
  84. key bool
  85. }
  86. // Field function returns field value.
  87. func (e ModuleValidationError) Field() string { return e.field }
  88. // Reason function returns reason value.
  89. func (e ModuleValidationError) Reason() string { return e.reason }
  90. // Cause function returns cause value.
  91. func (e ModuleValidationError) Cause() error { return e.cause }
  92. // Key function returns key value.
  93. func (e ModuleValidationError) Key() bool { return e.key }
  94. // ErrorName returns error name.
  95. func (e ModuleValidationError) ErrorName() string { return "ModuleValidationError" }
  96. // Error satisfies the builtin error interface
  97. func (e ModuleValidationError) Error() string {
  98. cause := ""
  99. if e.cause != nil {
  100. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  101. }
  102. key := ""
  103. if e.key {
  104. key = "key for "
  105. }
  106. return fmt.Sprintf(
  107. "invalid %sModule.%s: %s%s",
  108. key,
  109. e.field,
  110. e.reason,
  111. cause)
  112. }
  113. var _ error = ModuleValidationError{}
  114. var _ interface {
  115. Field() string
  116. Reason() string
  117. Key() bool
  118. Cause() error
  119. ErrorName() string
  120. } = ModuleValidationError{}
  121. // Validate checks the field values on ModuleFile with the rules defined in the
  122. // proto definition for this message. If any rules are violated, an error is returned.
  123. func (m *ModuleFile) Validate() error {
  124. if m == nil {
  125. return nil
  126. }
  127. // no validation rules for Path
  128. // no validation rules for Content
  129. return nil
  130. }
  131. // ModuleFileValidationError is the validation error returned by
  132. // ModuleFile.Validate if the designated constraints aren't met.
  133. type ModuleFileValidationError struct {
  134. field string
  135. reason string
  136. cause error
  137. key bool
  138. }
  139. // Field function returns field value.
  140. func (e ModuleFileValidationError) Field() string { return e.field }
  141. // Reason function returns reason value.
  142. func (e ModuleFileValidationError) Reason() string { return e.reason }
  143. // Cause function returns cause value.
  144. func (e ModuleFileValidationError) Cause() error { return e.cause }
  145. // Key function returns key value.
  146. func (e ModuleFileValidationError) Key() bool { return e.key }
  147. // ErrorName returns error name.
  148. func (e ModuleFileValidationError) ErrorName() string { return "ModuleFileValidationError" }
  149. // Error satisfies the builtin error interface
  150. func (e ModuleFileValidationError) Error() string {
  151. cause := ""
  152. if e.cause != nil {
  153. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  154. }
  155. key := ""
  156. if e.key {
  157. key = "key for "
  158. }
  159. return fmt.Sprintf(
  160. "invalid %sModuleFile.%s: %s%s",
  161. key,
  162. e.field,
  163. e.reason,
  164. cause)
  165. }
  166. var _ error = ModuleFileValidationError{}
  167. var _ interface {
  168. Field() string
  169. Reason() string
  170. Key() bool
  171. Cause() error
  172. ErrorName() string
  173. } = ModuleFileValidationError{}
  174. // Validate checks the field values on ModuleName with the rules defined in the
  175. // proto definition for this message. If any rules are violated, an error is returned.
  176. func (m *ModuleName) Validate() error {
  177. if m == nil {
  178. return nil
  179. }
  180. // no validation rules for Remote
  181. // no validation rules for Owner
  182. // no validation rules for Repository
  183. // no validation rules for Version
  184. // no validation rules for Digest
  185. return nil
  186. }
  187. // ModuleNameValidationError is the validation error returned by
  188. // ModuleName.Validate if the designated constraints aren't met.
  189. type ModuleNameValidationError struct {
  190. field string
  191. reason string
  192. cause error
  193. key bool
  194. }
  195. // Field function returns field value.
  196. func (e ModuleNameValidationError) Field() string { return e.field }
  197. // Reason function returns reason value.
  198. func (e ModuleNameValidationError) Reason() string { return e.reason }
  199. // Cause function returns cause value.
  200. func (e ModuleNameValidationError) Cause() error { return e.cause }
  201. // Key function returns key value.
  202. func (e ModuleNameValidationError) Key() bool { return e.key }
  203. // ErrorName returns error name.
  204. func (e ModuleNameValidationError) ErrorName() string { return "ModuleNameValidationError" }
  205. // Error satisfies the builtin error interface
  206. func (e ModuleNameValidationError) Error() string {
  207. cause := ""
  208. if e.cause != nil {
  209. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  210. }
  211. key := ""
  212. if e.key {
  213. key = "key for "
  214. }
  215. return fmt.Sprintf(
  216. "invalid %sModuleName.%s: %s%s",
  217. key,
  218. e.field,
  219. e.reason,
  220. cause)
  221. }
  222. var _ error = ModuleNameValidationError{}
  223. var _ interface {
  224. Field() string
  225. Reason() string
  226. Key() bool
  227. Cause() error
  228. ErrorName() string
  229. } = ModuleNameValidationError{}